2011-02-23 8 views
3

그래서 제 3 자 서비스에 연결하고 PHP에서 몇 가지 문제를 겪고 있습니다. 내가 WebService에 스튜디오의 서비스 요청을하려고하면 잘 작동하고 전송 요청은 다음과 같습니다다른 SOAP SOAP 요청을 생성하는 PHP SoapClient

<?xml version="1.0" encoding="utf-16"?> 
<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> 
     <createUser xmlns="http://ws.example.com"> 
      <arg0 xmlns="">[email protected]</arg0> 
      <arg1 xmlns="">123</arg1> 
      <arg2 xmlns="">1234</arg2> 
      <arg3 xmlns="">1234567890abcdef</arg3> 
      <arg4 xmlns="">test</arg4> 
      <arg5 xmlns="">user</arg5> 
      <arg6 xmlns="">02472</arg6> 
      <arg7 xmlns="">[email protected]</arg7> 
      <arg8 xmlns="">A</arg8> 
      <arg9 xmlns="">0</arg9> 
      <arg10 xmlns="">true</arg10> 
     </createUser> 
    </soap:Body> 
</soap:Envelope> 

를 이제 다음 명령을 사용하여 PHP에서 서비스를 호출 할 때 :

$this->web_service->createAccount('[email protected]', 123, 1234, '1234567890abcdef', 'test', 'user', '12345', '[email protected]', 'A', 0, true) 

및 요청을 디버깅하면 다음과 같이 나타납니다.

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.example.com"> 
    <SOAP-ENV:Body> 
     <ns1:createUser/> 
     <param1>123</param1> 
     <param2>1234</param2> 
     <param3>1234567890abdcef</param3> 
     <param4>test</param4> 
     <param5>user</param5> 
     <param6>12345</param6> 
     <param7>[email protected]</param7> 
     <param8>A</param8> 
     <param9>0</param9> 
     <param10>true</param10> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

PHP에서 SoapClient에 의해 생성 된 요청으로 인해 즉시 몇 가지 문제가 발생합니다. 첫 번째 것은 첫 번째 매개 변수 (처음 [email protected]을 전달)가 param1에 전달되지 않고 두 번째 매개 변수가 전달된다는 것입니다. 다음으로 createUser에 대한 요청은 전달되는 매개 변수를 포함하지 않는 자체 닫기 태그입니다. 그러면 분명히 전체 구조가 사용되는 태그와 조금 다릅니다.

__call()을 사용하여 SoapParam의 매개 변수를 래핑하고 __soapCall()을 사용하지만 이러한 문제를 수정하지 않는 배열을 사용해 보았습니다. 요청을 처리하는 데까지 이르지 않았습니다.

PHP의 SoapClient가 생성 한 요청과 WebService Studio가 생성 한 요청이 수동으로 수동으로 생성되지 않도록이 문제를 해결할 수있는 사람은 누구입니까?

+0

WSDL을 사용하여 서비스에 연결하고 있습니까? createAccount 메소드의 정의는 무엇입니까? – Cfreak

+0

WSDL을 사용하고 있지만 해당 정보를 공개 할 수 없습니다. – ryanzec

답변

0

난 당신이 더 나은 지표

$this->webService->createAccount(array('arg0'=>'[email protected]')...); 

또는 __soapCall 기능

+0

시도했지만 작동하지 않았습니다. – ryanzec

+0

이 방법을 시도한 후에 getLastRequest 호출 결과를 게시 할 수 있습니까? –

6

내가 (자기 폐쇄 작업 태그) 비슷한 문제가 있었다를 사용

에 대한 매개 변수 이름 배열을 사용하여 제공 할 수있다 생각

밝혀졌지만 문제는 내가 매개 변수를 전달하는 방법과 관련이있었습니다. 다음 예상 파라미터 WSDL에서 정의 하였다 :

<s:element name="ValidateStudent"> 
<s:complexType> 
<s:sequence> 
    <s:element minOccurs="0" maxOccurs="1" name="studentNumber" type="s:string" /> 
    <s:element minOccurs="0" maxOccurs="1" name="surname" type="s:string" /> 
    <s:element minOccurs="0" maxOccurs="1" name="dob" type="s:string" /> 
    <s:element minOccurs="0" maxOccurs="1" name="clientIP" type="s:string" /> 
    <s:element minOccurs="0" maxOccurs="1" name="clientUserAgent" type="s:string" /> 
    <s:element minOccurs="0" maxOccurs="1" name="clientReferrer" type="s:string" /> 
</s:sequence> 
</s:complexType> 
</s:element> 



<wsdl:message name="ValidateStudentSoapIn"> 
    <wsdl:part name="parameters" element="tns:ValidateStudent" /> 
</wsdl:message> 



<wsdl:operation name="ValidateStudent"> 
    <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Validation of user credentials to student portal</wsdl:documentation> 
    <wsdl:input message="tns:ValidateStudentSoapIn" /> 
    <wsdl:output message="tns:ValidateStudentSoapOut" /> 
</wsdl:operation> 



<wsdl:operation name="ValidateStudent"> 
    <soap:operation soapAction="http://test.example.com/ValidateStudent" style="document" /> 
    <wsdl:input> 
    <soap:body use="literal" /> 
    </wsdl:input> 
    <wsdl:output> 
    <soap:body use="literal" /> 
    </wsdl:output> 
</wsdl:operation> 
그래서 방법 ValidateStudent()는 (도 ValidateStudent 호출 -이 제 2 섹션에 정의 된) 하나 개의 파라미터 기대

복잡한 유형 인 첫 번째 절에서 정의 된대로.

$soapParams = array('ValidateStudent' => array(
    'studentNumber'  => $stuCode, 
    'surname'   => $lastName, 
    'dob'    => $dob, 
    'clientIP'   => $ip, 
    'clientUserAgent' => $uAgent, 
    'clientReferrer' => $referer 
)); 

$response = $soapClient->__soapCall('ValidateStudent', $soapParams); 

을 그러니까 기본적으로, (은 WSDL에 정의라는 이름으로 하위 요소 'ValidateStudent'로 키가 하나의 요소로) 나의 경우

, 나는 다음과 같이 PARAMS을 통과했다 작업중인 WSDL에 정의 된대로 정의를 이해하고 구조를 T에 따라야합니다.

+0

동일한 문제가있어서 SOAP 요청의 모든 하위 그룹/노드를 고려하여 사용자와 같은 배열 구조를 작성했습니다. – gyss