如何:PHP SoapClient示例合并WSSE标头

时间:2013-12-03 08:38:51

标签: php soap soap-client

我有一个WSDL文件。使用SOAP UI,我能够生成SOAP请求消息......

请求SOAP消息:

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

以下是响应SOAP消息:

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

问题:

使用PHP的SoapClient,我该怎么做:

  1. init SoapClient并加载WSDL文件(位于我的服务器中)?
  2. 设置标题?
  3. 发送SOAP请求?
  4. 最后,获取SOAP响应并将 Output1,Output2和Output3 的值提取到变量中?
  5. 我浏览了之前有关SOAP和WSSE标头的StackOverflow问题,但找不到答案。

    非常感谢您的时间和专家的帮助!

    PS:我可以使用cURL完成上述操作。但我想知道如何使用SoapClient来做到这一点。再次感谢!

0 个答案:

没有答案