PHP SOAP xml namespace missing from WSDL - php

I am trying to connect to a SOAP server with PHP in WSDL mode.
In the WSDL file there are defined serveral xmlns in the header.
I am creating a request with the client like this:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="NS1" xmlns:ns2="NS2" xmlns:ns3="NS3">
<env:Body>
<ns3:calculate>
<ns1:something>01</ns1:something>
<ns3:calcnode>
<ns1:beginning>2020-07-01</ns1:beginning>
<ns3:data>
<ns1:Hauptfaelligkeit>01.07</ns1:Hauptfaelligkeit>
<ns3:someothernode>
<ns3:code>AH</ns3:code>
<EL-Sum SumCd="ABC" Sum="20000000"/>
<ns3:something>VB</ns3:something>
<EL-Test TestCd="A" TestVal="9"/>
</ns3:someothernode>
</ns3:data>
</ns3:calcnode>
</ns3:calculate>
</env:Body>
</env:Envelope>
I've modified it a bit because the WSDL is confidental so I cannot provide it.
The problem is with there should be a NS4 but it isn't imported so the SOAP server doesn't get the value.
I found a solution that I can modify the XSD of NS4 and add elementFormDefault=qualified but I cannot do this because I cannot load the locally need to leave them remote.
Can I add the NS manually in the header?
Thanks

Related

php Soapserver empty php://input

I am setting up a soapserver and for some reason when trying to connect file_get_contents('php://input') is empty.
In Fiddler I can see that the clientprogram is actually sending the following:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><AuthenticationHeader xmlns="http://www.cito.nl/DULTService/"><Username>dult</Username><Password>dult</Password><Brincode>99DE00</Brincode></AuthenticationHeader></soap:Header><soap:Body><DULTValidateCredentials xmlns="http://www.cito.nl/DULTService/" /></soap:Body></soap:Envelope>
The soapclient sends two empty calls first, before sending the one above, not sure if that could be related.
Any help is much appreciated!

PHP SOAP request fails

I have to send a request to a remote SOAP endpoint. This is the SOAP request that PHP generates, and it fails:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org">
<SOAP-ENV:Body>
<ns1:GetParameterList>
<param>TKERES</param>
</ns1:GetParameterList>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
If I write the request XML manually this way and send it via cURL, it works perfectly:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<GetParameterList xmlns="http://tempuri.org">
<param>TKERES</param>
</GetParameterList>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Why do the first fail while the second one works correctly?
What is obvious here is that your first snippet (the one that doesn't work) is different from the one that works.
Specifically the property below looks to be in totally different places.
xmlns="http://tempuri.org"
I know from experience with SOAP that sometimes a change like this can cause it to fail. So, try if you can to adjust the way that PHP generates the request in order to match it with your XML hand written one.

Indesign Server soap response

I need to debug a soap webservice but i don't know where to start.
This is returning wrong data and i need to find why.
It is running on http://localhost:18385 and i can control the parameters that i send but don't know the endpoint file .
if i write http://localhost:18385 on browser i get
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:IDSP="http://ns.adobe.com/InDesign/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>HTTP GET method not implemented</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Thanks in advance
The easiest way to debug is to use an app like Postman or SoapUI, so you can set up what you post and see the response in detail.
You are getting an error because you are using GET in your script, InDesign Server expects POST request with Content-Type of xml/text and Body set to the Soap call, e.g.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://ns.adobe.com/InDesign/soap/">
<soapenv:Body>
<soap:RunScript>
<runScriptParameters>
<scriptLanguage>javascript</scriptLanguage>
<scriptFile>C:\InDesign\scriptfile.jsx</scriptFile>
<scriptArgs>
<name>myParameter</name>
<value>305</value>
</scriptArgs>
</runScriptParameters>
</soap:RunScript>
</soapenv:Body>
</soapenv:Envelope>
You're not giving much detail of what exactly you need.
If you're asking what's the WSDL path, it should be: http://localhost:18385/service?wsdl
If you need to debug a SOAP web service response you can either create a PHP test script using SoapClient or use SoapUI.

PHP SOAP Why are parameters not being sent?

I need to send a SOAP request to a .NET Web Services (*.asmx). I am creating a WSDL SoapClient object and I need to make a __soapCall sending 2 parameters: LoginName and Password. The XML should be something like the exemple to work, but the XML created has the parameters all confused.
This is the code:
$client = new SoapClient("https://server/service.asmx?WSDL",array("trace"=>1,'soap_version' => SOAP_1_2));
$client->__setCookie('ticket',$ticket);
$param= array('LoginName'=>'name','Password'=> base64_encode('123456'));
$client->__soapCall('AddPlayer', $param);
echo "REQUEST:\n" . htmlentities($sweepStakesClient->__getLastRequest()) . "\n";
Also tried:
$param = array(new SoapParam('name','LoginName'),new SoapParam(base64_encode('123456'),'Password'));
Echo returns:
REQUEST: <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://server.com/Service">
<env:Body>
<ns1:AddPlayer/>
<Password>MTIyMzQ1NTY=</Password>
</env:Body>
</env:Envelope>
I need it to be something like:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<AddPlayer xmlns="http://server.com/Service">
<request>
<LoginName>name</LoginName>
<Password>MTIyMzQ1NTY=</Password>
</request>
</AddPlayer>
</soap12:Body>
</soap12:Envelope>
Please pay attention to the documentation provided on php.net regarding the method you use here, SoapClient::__soapCall():
This is a low level API function that is used to make a SOAP call. Usually, in WSDL mode, SOAP functions can be called as methods of the SoapClient object. This method is useful in non-WSDL mode when soapaction is unknown, uri differs from the default or when sending and/or receiving SOAP Headers.
You're in WSDL mode, so you don't need to use it at all. Instead call the method directly:
$client->AddPlayer('name', 'MTIyMzQ1NTY');
When you debug you should see that it matches up with the method name and the two parameters. In case not, fall-back to SoapClient::__call() and use the array with the named parameters again as second parameter. But it's much more comfortable to do it the WSDL style with named methods.

SOAP Web Service accessing with PHP, need a blank Header

this is what I generate using the SoapClient PHP class.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:sap-com:document:sap:soap:functions:mc-style">
<SOAP-ENV:Body>
<ns1:_-bic_-nf2>
<ETColumnDescription/>
<ETGridData/>
<ETMessageLog/>
<ETRowDescription/>
<ISVar_01xwerbet>
<Sign>I</Sign>
<Option>LE</Option>
<Low>3</Low>
<High/>
</ISVar_01xwerbet>
</ns1:_-bic_-nf2>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
What I also need is a blank header which should look like <SOAP-ENV:Header/>
right before <SOAP-ENV:Body>
But doing it with SOAPHeader: $header = new SOAPHeader('urn:sap-com:document:sap:soap:functions:mc-style',null,null) doesnt seem to be working. Tried everything. Any other ideas?
What I also need is, to remove the first line <?xml version="1.0" encoding="UTF-8"?> before sending the request, I think the server doesn't like it, would that be possible?
If it helps, this is for a SAP Web Service.
Thank you in advance.
It is possible. Just refer the nusoap.php file in libraries. You can modify the header which is normally present under the variable $headers.
I tried and it worked for me.

Categories