SOAP Web Service accessing with PHP, need a blank Header - php

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.

Related

PHP SOAP xml namespace missing from WSDL

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

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.

How to make SOAP Api client request?

I just need to make the call.
http://api.linnlive.com/stats.asmx?op=SimpleGenericQuery
I want to use that, within a web page, to run a query and return the data, something like this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.linnlive.com/stats">
<SOAP-ENV:Body>
<ns1:SimpleGenericQueryCSV>
<ns1:Token>INSERT YOUR TOKEN HERE</ns1:Token>
<ns1:sqlQuery>select * from stockitem where blogicaldelete = '1'</ns1:sqlQuery>
</ns1:SimpleGenericQueryCSV>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But what do I do?
I've tried making an xml file and doing something like this:
<?php
$xml = simplexml_load_file("/lookup.xml");
echo "result: ".$xml
?>
But I get a blank, any ideas? What is the correct way?

How to send hashed data in SOAP request body?

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?

Categories