How to provide SOAP API policy/extension requirements in SOAP client
P粉511896716
P粉511896716 2023-08-29 20:09:01
0
1
533
<p>I need to connect to a soap api...I've used the soap api a few times now, but since 99% of the apis are resting now I haven't used them in several years</p> ; <p>When I call the api using soap client, I get </p> <pre class="brush:php;toolbar:false;">SOAP-ERROR: Parsing WSDL: Unknown required WSDL extension 'http://schemas.xmlsoap.org/ws/2004/09/policy'</ pre> <p>So when I open the wsdl address in browser (login/password protected) I can see these lines in the xml output</p> <pre class="brush:php;toolbar:false;"><wsdl:definitions xmlns:p1="urn:haixin:all2crm" xmlns:wsp="http://schemas.xmlsoap.org/ ws/2004/09/policy" "http://schemas.xmlsoap.org/wsdl/" name="SI_USBPC_REQUEST" targetNamespace="urn:haixin:all2crm"> <wsdl:documentation/> <wsp:UsingPolicy wsdl:required="true"/> <wsp:Policy wsu:Id="OP_SI_USBPC_REQUEST"/></pre> <p>Where I have it</p> <pre class="brush:php;toolbar:false;"><wsp:Policy> <wsp:PolicyReference URI="#OP_SI_USBPC_REQUEST"/> </wsp:Policy></pre> <p>When I search for this error, I can only find 1 resource in the entire internet where the answer is to turn off the policy requirement, which is: <code><wsp:UsingPolicy wsdl:required="false"/> </code> but I don't own the api, so when I search for the policy name <code>OP_SI_USBPC_REQUEST</code> there is no problem, I don't get any results, so I guess this is set by the api owner Some custom names</p> <p>So my question is should I make the policy and attach it to the soap client request? What is the connection between policy and extensions as I am getting extension missing error but if I turn off the policy requirement it goes away </p> <p>Is there somewhere I can download the extension? What is the format...should I append them to the soap client request? </p> <p>Or is it something that should be installed on the server? If I add the extension somehow, will the error go away because I've appended the username/password to the api call, or is this just the first step and I should handle the policy requirement after that?</p> <p>By the way, I use php to call the api, this is my code</p> <pre class="brush:php;toolbar:false;">$options = [ 'login' => 'mlogin', 'password' => 'mypassword', ]; $client = new \SoapClient("http://domain:port/dir/wsdl/?p=sa/92130e1ffa97338ba2d1fc026567031d" , $options );</pre> <p>If I download the xml and turn off the requirement for a local file and use that file address in the soap client, can I use that file to talk to the api? (My understanding is that the xml doesn't contain any actual data, it's just the interface/definition for the soap client and I can't use a local file to talk to the online api, or maybe I'm wrong?) </p>
P粉511896716
P粉511896716

reply all(1)
P粉916553895

The message "Unknown required WSDL extension" means SoapClient found an element externally The wsdl:required property of the WSDL namespace is set to true (As you can see here).

So, to avoid this error, one way is to set the wsdl:required property to false.

It is entirely possible to download the WSDL file, modify it and use a local copy. Just make sure to use Absolute path, as shown in here.

By the way, "policy" in this context refers to the WS-Policy specification.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!