如何在WSDL中要求身份验证肥皂头?

Dmi*_*ine 6 php soap wsdl

我用php创建了一个web服务SOAPServer.它希望看到一个SoapHeader UsernameToken用户名和密码元素.当我在请求中包含此标头时,一切都工作正常.只需在名为"UsernameToken"的Soap处理程序类中定义一个方法,就会调用此方法并将stdClass Obj传递给它.然后我可以通过$Obj->username和验证用户$Obj->password.

我不知道要添加到WSDL文件中的内容首先要定义此UsernameToken标头,然后如何在WSDL中指示它是必需的?

我在某处读到过新的SOAP标准不赞成"必需"标题的概念.

关于如何至少指出的任何建议是我的wsdl请求应该包括这个标题?

Tim*_*ens 3

以下是指定登录的 WSDL 示例:https://ws1.webservices.nl/soap_doclit ?wsdl

<binding name="Webservices.nlBinding" type="tns:Webservices.nlPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="login">
<soap:operation soapAction="https://ws1.webservices.nl/soap_doclit.php/login" style="document"/>
<input>
<soap:body use="literal"/>
<soap:header message="tns:Headers" part="HeaderLogin" use="literal"/>
<soap:header message="tns:Headers" part="HeaderAuthenticate" use="literal"/>
</input>
Run Code Online (Sandbox Code Playgroud)

  • 您的答案实际上并没有回答以下问题:“如何在 WSDL 中表明它是必需的?” 毕竟这只是一个票价起点。 (2认同)