2010-03-16 2 views
7

PHP와 SOAP에 대한 많은 질문이 있습니다. 그러나 나는 내 상황에 대한 답을 찾지 못했다.PHP와 SOAP. 변경 봉투

So. 나는 그것을 위해 PHP SoapClient와 WSDL을 사용한다. 개체가이 전송 :

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.site.com"><SOAP-ENV:Body> 

을하지만이 필요합니다

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body> 

질문. 표준 PHP 클래스 SoapClient로 어떻게이 작업을 수행 할 수 있습니까?

감사합니다.

+0

WSDL이 올바르지 않습니다. SOAP 서버 조각도 만들었습니까? – Clutch

+0

아니요, 다른 라이브러리 (C# 용 ActiveX 컨트롤)가 제대로 작동하고 실제 네임 스페이스를 보내기 때문에 WSDL이 정확합니다. SOAP 서버를 변경할 수 없습니다. 서비스 기능에 액세스하려면이 도구를 사용해야합니다. – Oleg

+0

이것이 SOAP 서비스와 통신하는 데 문제를 일으키는 것으로 생각되는 경우 이는 잘못된 가정 일 수 있습니다. 방금 발생한 것처럼 메시지에 누락 된 속성과 관련된 오류 일 수 있습니다. – bytespider

답변

5

내가 php.net

<?php 
class MSSoapClient extends SoapClient { 

    function __doRequest($request, $location, $action, $version) { 
     $namespace = "http://tempuri.com"; 

     $request = preg_replace('/<ns1:(\w+)/', '<$1 xmlns="'.$namespace.'"', $request, 1); 
     $request = preg_replace('/<ns1:(\w+)/', '<$1', $request); 
     $request = str_replace(array('/ns1:', 'xmlns:ns1="'.$namespace.'"'), array('/', ''), $request); 

     // parent call 
     return parent::__doRequest($request, $location, $action, $version); 
    } 
} 

$client = new MSSoapClient(...); 
?> 

요청이 코드 변경 봉투에 답을 검색 할 수 있습니다. 그리고 ASP SOAP 서버가 필요합니다.