1

I'm using PHP 5.5.9 Soap to access a web service and using a WSSoapClient (noted from here: how to implement ws-security 1.1 in php5) to help with the security. Not sure I can share the WSDL at this time. I'm getting a null response value when I call a function, but the __getLastResponse value has the XML data showing all the expected fields I see in SoapUI.

There are two functions defined in the WSDL that I'm calling, though I'm only seeing the issue with one. They both take the same arguments and I just copied the script and changed the function names to compare results, so I know there aren't typos, etc.

Function that works (Identity):

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

Function that doesn't work (IdentityInterface):

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

When I use var_dump I get the expected object for the 'Identity' function output. When I use it for 'IdentityInterface' I get a NULL return. The __getLastResponse() output shows the XML as I'd expect it in both cases.

Identity Response:

<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 Response:

<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>

I'd seen some references that the WSDL may not be returning properly formatted XML, but don't see those types of errors when testing it in SoapUI. If I can't upload the WSDL, what would I need to look for to determine why this is happening.

UPDATED with WSDL info:

 <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>

Thank you in advance.

Community
  • 1
  • 1
  • For more pointers you could show the response XML(s). If those contain secret information, redact those parts. For the WSDL check if it's got a public URI, then you could share the URI (and not the WSDL document itself). – hakre Jul 30 '14 at 11:42
  • Still working on this, but I believe that the issue is that the response is not properly formatted. After looking at the WSDL in Eclipse, I noted that the IdentityInterface function looks to be expecting an output in the form of an "IdentityInterfaceResponse". However, as you can see from the above getLastReponse output, the query is returning an IdentityResponse. Pretty sure this is it, but still checking. – user3888913 Aug 19 '14 at 14:18
  • that must not be an issue. If IdentityResponse is a IdentityInterfaceResponse (or implements it), this would be fine (and an option just by the names). So check the WSDL for subclasses/subtypes, too. – hakre Aug 22 '14 at 17:18
  • Added some of the WSDL elements - are these the sections to look for? Sorry, not WSDL savvy. Can you override the expected return format? The WSDL can't be changed. – user3888913 Aug 25 '14 at 19:38
  • @hakre - I was looking at this post: [Stackoverflow - SoapClient Returns “NULL”, but __getLastResponse() returns XML](http://stackoverflow.com/questions/17441335/soapclient-returns-null-but-getlastresponse-returns-xml) and it seemed to be the same issue. I can't tell, however, what changed to make that work. How can I tell PHP to not worry about the response output type? Do I have to simply grab the response headers and parse them as XML? Thanks! – user3888913 Aug 27 '14 at 15:00
  • Anyone have any thoughts? Is it possible to change the namespace returned in the response? – user3888913 Sep 03 '14 at 16:16
  • Changing the Namespace will actually break it. The Namespace is a fixed point in time you can't change w/o changing the meaning. You probably mean to re-write namespace prefixes which must not be necessary or it's just not SOAP/XML. – hakre Sep 03 '14 at 21:43
  • I see. It would appear that because the XML response is technically invalid when compared with the WSDL that the PHP function won't accept it. Is there a way to override or workaround this? – user3888913 Sep 04 '14 at 13:15
  • One way to deal with invalid XML in SOAP responses is to proxy the interaction with the remote service and process the result in fixing it so that afterwards it is consumable again. Alternatively, contact the support of the service vendor and highlight the issue with their response. It's normally of more benfit to get things fixed where problems occur - not later on. – hakre Sep 08 '14 at 09:18

0 Answers0