PHP Soap变量null但__getLastResponse返回XML

时间:2014-07-29 19:04:49

标签: php xml web-services soap wsdl

我正在使用PHP 5.5.9 Soap访问Web服务并使用WSSoapClient(在此处注明:how to implement ws-security 1.1 in php5)来帮助提高安全性。我不确定此时是否可以共享WSDL。我在调用函数时得到一个空响应值,但是__getLastResponse值的XML数据显示了我在SoapUI中看到的所有预期字段。

我正在调用WSDL中定义的两个函数,尽管我只看到了一个函数。他们都采用相同的参数,我只是复制了脚本并更改了函数名称以比较结果,所以我知道没有拼写错误等。

有效的功能(身份):

$params = array("IdentityRequest" => array("IdentityPersonRequest" => array("IdentityID" => $userid,"InterfaceID" => $interfaceID)));
$response = $client->__call('Identity',$params);

不起作用的功能(IdentityInterface):

$params = array("IdentityInterfaceRequest" => array("IdentityPersonRequest" => array("IdentityID" => $userid,"InterfaceID" => $interfaceID)));
$response = $client->__call('IdentityInterface',$params);

当我使用var_dump时,我得到'Identity'函数输出的预期对象。当我将它用于'IdentityInterface'时,我得到一个NULL返回。 __getLastResponse()输出显示了我在两种情况下都期望的XML。

身份响应:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
        <SOAP-ENV:Body>
            <ns5:IdentityResponse xmlns:ns5="http://company-url-stuff/it/contract/IdentityService/v1" xmlns:ns2="http://company-url-stuff/it/msg/v1" xmlns:ns3="http://company-url-stuff/it/data/v1" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns="">
                <ns5:IdentityCompositeInformation>
                    <ns3:IdentityPersonResponse>
                        <ns3:IdentityPersonType>
                            <ns3:PersonInformation>
                                <ns3:Name>Jones, Joe J.</ns3:Name>
                                <ns3:SalutationPreferredName> </ns3:SalutationPreferredName>
                                <ns3:GivenName>Joe </ns3:GivenName>
                                <ns3:MiddleName>J.</ns3:MiddleName>
                                <ns3:FamilyName>Jones</ns3:FamilyName>
                            </ns3:PersonInformation>
                            <ns3:PersonBusinessInformation>
                                <ns3:IdentityID>000000</ns3:IdentityID>
                                <ns3:PersonAccount>
                                    <ns3:NTID>jjones</ns3:NTID>
                                </ns3:PersonAccount>
                                <ns3:PersonFinance>
                                    <ns3:BusinessUnitName>Management</ns3:BusinessUnitName>
                                </ns3:PersonFinance>
                            </ns3:PersonBusinessInformation>
                        </ns3:IdentityPersonType>
                        <ns3:IdentityType>
                            <ns3:IdentityType>E</ns3:IdentityType>
                        </ns3:IdentityType>
                    </ns3:IdentityPersonResponse>
                <ns3:IdentityEntitlementResponse/>
            </ns5:IdentityCompositeInformation>
        </ns5:IdentityResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

IdentityInterface响应:

<SOAP-ENV:Envelope
   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
        <SOAP-ENV:Header/>
            <SOAP-ENV:Body>
                <ns5:IdentityResponse xmlns:ns5="http://company-url-stuff/it/contract/IdentityService/v1" xmlns:ns2="http://company-url-stuff/it/msg/v1"
   xmlns:ns3="http://company-url-stuff/it/data/v1"
   xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns="">
                    <ns5:IdentityCompositeInformation>
                        <ns3:IdentityPersonResponse>
                            <ns3:IdentityPersonType>
                                <ns3:PersonInformation>
                                    <ns3:GivenName>Joe</ns3:GivenName>
                                    <ns3:MiddleName>J.</ns3:MiddleName>
                                    <ns3:FamilyName>Jones</ns3:FamilyName>
                                </ns3:PersonInformation>
                                <ns3:PersonBusinessInformation>
                                    <ns3:IdentityID>000000</ns3:IdentityID>
                                    <ns3:PersonAccount>
                                        <ns3:NTID>jjones</ns3:NTID></ns3:PersonAccount>
                                    <ns3:PersonPosition>
                                        <ns3:JobCode>123456</ns3:JobCode>
                                        <ns3:JobTitle>Manager</ns3:JobTitle>
                                        <ns3:FullPartTime>F</ns3:FullPartTime>
                                        <ns3:MgrLevelDesc>Manager</ns3:MgrLevelDesc>
                                        <ns3:EmpReports>N</ns3:EmpReports>
                                        <ns3:ReportingManager>
                                            <ns3:ID>456798</ns3:ID>
                                        </ns3:ReportingManager>
                                    </ns3:PersonPosition>
                                    <ns3:PersonFinance>
                                        <ns3:DeptID>ID1234</ns3:DeptID>
                                        <ns3:DeptName>Dispatch</ns3:DeptName>
                                        <ns3:CompanyCode>US1</ns3:CompanyCode>
                                        <ns3:CostCenter>US10CC</ns3:CostCenter>
                                        <ns3:CountryCode>US</ns3:CountryCode>
                                    </ns3:PersonFinance>
                                    <ns3:PersonContact>
                                        <ns3:EmailAddress>jjones@company.com</ns3:EmailAddress>
                                        <ns3:PersonLocation>
                                            <ns3:Region>NAMERICA</ns3:Region>
                                            <ns3:AddressInfo>
                                                <ns3:City>New York</ns3:City>
                                                <ns3:County> </ns3:County>
                                                <ns3:Province>NY</ns3:Province>
                                                <ns3:CountryName>US</ns3:CountryName>
                                                <ns3:Description>BUSINESS_ADDRESS</ns3:Description>
                                            </ns3:AddressInfo>
                                        </ns3:PersonLocation>
                                    </ns3:PersonContact>
                                </ns3:PersonBusinessInformation>
                            </ns3:IdentityPersonType>
                            <ns3:IdentityType>
                                <ns3:IdentityType>E</ns3:IdentityType>
                            </ns3:IdentityType>
                        </ns3:IdentityPersonResponse>
                    <ns3:IdentityEntitlementResponse/>
                </ns5:IdentityCompositeInformation>
            </ns5:IdentityResponse>
        </SOAP-ENV:Body>
       </SOAP-ENV:Envelope>

我看到一些引用,WSDL可能没有返回格式正确的XML,但是在SoapUI中测试时看不到那些类型的错误。如果我无法上传WSDL,我需要寻找什么来确定为什么会发生这种情况。

使用WSDL信息更新:

 <xsd:element name="IdentityInterfaceResponse" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <xsd:sequence xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <xsd:element maxOccurs="unbounded" minOccurs="0" name="IdentityCompositeInformation" type="data:IdentityCompositeInformationType" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
     </xsd:sequence>
   </xsd:complexType>
 </xsd:element>
<message name="IdentityInterfaceResponse">
  <part name="IdentityInterfaceResponse" element="sch0:IdentityInterfaceResponse"/>
</message>
<message name="IdentityInterfaceRequest">
  <part name="IdentityInterfaceRequest" element="sch0:IdentityInterfaceRequest"/>
</message>
<message name="IdentityResponse">
  <part name="IdentityResponse" element="sch0:IdentityResponse"/>
</message>
<message name="IdentityImageRequest">
  <part name="IdentityImageRequest" element="sch0:IdentityImageRequest"/>
</message>
<message name="IdentityRequest">
  <part name="IdentityRequest" element="sch0:IdentityRequest"/>
</message>
<message name="IdentityImageResponse">
  <part name="IdentityImageResponse" element="sch0:IdentityImageResponse"/>
</message>
<portType name="IdentityService">
  <operation name="IdentityInterface">
    <input name="IdentityInterfaceRequest" message="sch0:IdentityInterfaceRequest"/>
    <output name="IdentityInterfaceResponse" message="sch0:IdentityInterfaceResponse"/>
  </operation>
  <operation name="Identity">
    <input name="IdentityRequest" message="sch0:IdentityRequest"/>
    <output name="IdentityResponse" message="sch0:IdentityResponse"/>
  </operation>
  <operation name="IdentityImage">
    <input name="IdentityImageRequest" message="sch0:IdentityImageRequest"/>
    <output name="IdentityImageResponse" message="sch0:IdentityImageResponse"/>
  </operation>
</portType>
<binding name="IdentityServiceSoap11" type="sch0:IdentityService">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
  <operation name="IdentityInterface">
    <soap:operation soapAction=""/>
    <input name="IdentityInterfaceRequest">
      <soap:body use="literal"/>
  <wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#IdentityInterface_input_policy"/>
    </input>
    <output name="IdentityInterfaceResponse">
      <soap:body use="literal"/>
    </output>
  </operation>
  <operation name="Identity">
    <soap:operation soapAction=""/>
    <input name="IdentityRequest">
      <soap:body use="literal"/>
  <wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#Identity_input_policy"/>
    </input>
    <output name="IdentityResponse">
      <soap:body use="literal"/>
    </output>
  </operation>
  <operation name="IdentityImage">
    <soap:operation soapAction=""/>
    <input name="IdentityImageRequest">
      <soap:body use="literal"/>
  <wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#IdentityImage_input_policy"/>
    </input>
    <output name="IdentityImageResponse">
      <soap:body use="literal"/>
    </output>
  </operation>
</binding>

提前谢谢。

0 个答案:

没有答案