0

I have a WSDL file. Using SOAP UI, I was able to generate the SOAP request message...

Request SOAP message:

<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

<SOAP-ENV:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="1">
    <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="ABCGID-123456789">
        <wsse:Username>Spiderman</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">spinningtheweb</wsse:Password>
</wsse:UsernameToken>
    </wsse:Security>
</SOAP-ENV:Header>

<SOAP-ENV:Body>
    <FooInterface_Bar_Input xmlns="http://example.com/interfaces">
        <Input1>Howdy</Input1>
        <Input2>Partner</Input2>
    </FooInterface_Bar_Input>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

And here is the response SOAP message:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<SOAP-ENV:Body>
    <ns:FooInterface_Bar_Output xmlns:ns="http://example.com/interfaces">
    <ns:Output1>Banana</ns:Output1>
    <ns:Output2>Papaya</ns:Output2>
    <listOfOtherOutputs>
       <Output3>Apple</Output3>
    </listOfOtherOutputs>
</ns:FooInterface_Bar_Output>
</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

QUESTION:

Using PHP's SoapClient, how do I:

  1. init SoapClient and load the WSDL file (which sits in my server)?
  2. Set the header?
  3. Send the SOAP request?
  4. And finally, get a SOAP response back and extract the values of Output1, Output2, and Output3 into variables?

I've browse previous StackOverflow questions regarding SOAP and WSSE headers, but could not find the answer.

Thanks very much in advance for your time and your expert help!

PS: I can accomplish the above using cURL. But I want to know how to do it using SoapClient. Thanks again!

  • have you tried this solution http://stackoverflow.com/questions/953639/connecting-to-ws-security-protected-web-service-with-php ? – Mikaël DELSOL Dec 03 '13 at 11:48
  • @Mikaël DELSOL, the link did not help. As you can see from the SOAP response, they have namespaces in the tags. I'm having trouble extracting the data because I don't understand SoapClient enough (PHP's manual is also too complicated in its explanation) –  Dec 03 '13 at 23:52

0 Answers0