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.
Related
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.
I call a method with php soapClient class, like this:
$client->ResetAppPassword($request);
and my envelope is send like this
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://xmlns.xxxx.com/PATH/TO/V1/schema"
xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<SOAP-ENV:Body>
<ns1:ResetAppPasswordRequest>
<ns1:username>TEST</ns1:username>
<ns1:app>TEST</ns1:app>
</ns1:ResetAppPasswordRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But the server response:
The message must be an instance of: {http://www.w3.org/2003/05/soap-envelope}Envelope
and this is because the service is specting other format:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sch="http://xmlns.xxxx.com/PATH/TO/V1/schema">
<soap:Body>
<sch:ResetAppPasswordRequest>
<sch:username>TEST</sch:username>
<sch:app>DMS</sch:app>
</sch:ResetAppPasswordRequest>
</soap:Body>
</soap:Envelope>
So the i already tried to send it via php-CURL but with this solution I need to parse the XML response, so this make the process really hard, because I want to manage the response as an object.
Can someone help me... PLEASSSE..
I am writing PHP soap client.
I used wsdlbrowser to format the soap request correctly.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.iws.iaeste.net/">
<SOAP-ENV:Body>
<ns1:fetchOffers>
<token>
<token>..your token..</token>
</token>
<request>
<exchangeYear>2015</exchangeYear>
<fetchType>SHARED</fetchType></request>
</ns1:fetchOffers>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This would be correctly formatted soap request. Or to be specific, the code beetwen first token tag and last request tag is in the point of interest.
How would I transfer this request to PHP for sending it over SOAP?
THis question is connceted to: PHP Soap client, Java SOAP server
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.
I want to imitate following request using Zend_Soap_Client.
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<h3:__MethodSignature xsi:type="SOAP-ENC:methodSignature"
xmlns:h3="http://schemas.microsoft.com/clr/soap/messageProperties" SOAP-ENC:root="1"
xmlns:a2="http://schemas.microsoft.com/clr/ns/System.Collections">xsd:string a2:Hashtable</h3:__MethodSignature>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<i4:ReturnDataSet id="ref-1" xmlns:i4="http://schemas.microsoft.com/clr/nsassem/Interface.IRptSchedule/Interface">
<sProc id="ref-5">BU</sProc>
<ht href="#ref-6"/>
</i4:ReturnDataSet><br/>
<a2:Hashtable id="ref-6" xmlns:a2="http://schemas.microsoft.com/clr/ns/System.Collections">
<LoadFactor>0.72</LoadFactor>
<Version>1</Version>
<Comparer xsi:null="1"/>
<HashCodeProvider xsi:null="1"/>
<HashSize>11</HashSize>
<Keys href="#ref-7"/>
<Values href="#ref-8"/>
</a2:Hashtable>
<SOAP-ENC:Array id="ref-7" SOAP-ENC:arrayType="xsd:anyType[1]">
<item id="ref-9" xsi:type="SOAP-ENC:string">#AppName</item>
</SOAP-ENC:Array><br/>
<SOAP-ENC:Array id="ref-8" SOAP-ENC:arrayType="xsd:anyType[1]">
<item id="ref-10" xsi:type="SOAP-ENC:string">AAGENT</item>
</SOAP-ENC:Array>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
It seems somehow I've to send hashed "ref-7" and "ref-8" array embedded inside body? How can I do this?
Function ReturnDataSet takes two parameters, how can I send additional "ref-7" and "ref-8" array data?
$client = new SoapClient($wsdl_url, array('soap_version' => SOAP_1_1));
$result = $client->ReturnDataset("BU", $ht);
I don't know how to set $ht, so that hashed data is sent as different body entry.
Thanks.
have you tried sending a two-dimensional array as $ht? From looking at the code, $ht corresponds to a hashtable with ref-7 and ref-8 being an array themselves.
I tried to open this service in Visual Studio to get an idea of the type of parameters, but I recieved a few schema errors, mainly missing dataTypes. Are you sure this web service is configured and working like it should for others?