PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, November 22, 2022

[FIXED] How to provide SOAP API policy/extension requirement in the SOAP client

 November 22, 2022     api, php, soap     No comments   

Issue

i need to connect to a soap api ... now i've been working with soap api couple of times before but since 99% api are rest now it's been years since i've worked with them

when i call the api using soap client i get

SOAP-ERROR: Parsing WSDL: Unknown required WSDL extension 'http://schemas.xmlsoap.org/ws/2004/09/policy'

so when i open the wsdl address in my browser (login/password protected) i can see these lines in the xml output

<wsdl:definitions xmlns:p1="urn:haixin:all2crm" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsdl="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"/>

and down somewhere i have

<wsp:Policy>
<wsp:PolicyReference URI="#OP_SI_USBPC_REQUEST"/>
</wsp:Policy>

when i search this error i can only find 1 resource in the whole internet and the answer is to turn off the policy requirement ie : <wsp:UsingPolicy wsdl:required="false"/> but i dont own the api so thats out of question also when i search the policy name OP_SI_USBPC_REQUEST i get no result so im guessing this is some custom name set by api owner

so my question is should i produce the policy and attach them to the soap client request ? what is the connection between the policy and extension since im getting extension missing error but it would go away if i turn off the policy requirement

are extensions downloadable from somewhere ? whats the format ... and should i attach them to the soap client request ?

or it's something that should be installed on the server ? would error go away if i somehow add the extension since im already attaching username/password to api call or is that just the first step and should i handle the policy requirement after that ?

btw im using php to call the api and here is my code

    $options = [
        'login' => 'mlogin',
        'password' => 'mypassword',
    ];

    $client = new \SoapClient("http://domain:port/dir/wsdl/?p=sa/92130e1ffa97338ba2d1fc026567031d" , $options );

if i download the xml and turn off the requirement on my local file and use that file address in the soap client can i use the file to talk to the api ? (my understanding is the xml doesn't contain any actual data and it's just a interface/definition for soap client and i cant use my local file to talk to the online api or maybe im wrong ?)


Solution

The message "Unknown required WSDL extension " means that SoapClient found an element outside of the WSDL namespace with the wsdl:required attribute set to true (as you can see here).

So, to avoid the error, one way is to set the wsdl:required attribute to false indeed.

It is perfectly possible to download the WSDL file, modify it and use the local copy. Just make sure to use the absolute path, as indicated here.

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



Answered By - Olivier
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing