Convert xml request to array in php SoapClient - php

I have following xml file that I have to send as request to a Soap service from a SoapClient in php. I used the SoapVar to create array to sending request but the respond node is not present there. Anyone please , can you help me to convert this xml to array to make request to consume the Soap service
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns4:Send xmlns:ns4="hidden" xmlns="Envelope" xmlns:ns2="hidden" xmlns:ns3="hidden">
<ns4:Pack>
<Envelope>
<Header>
<ID>string</ID>
<StringFirst>string</ns2:StringFirst>
</Header>
<Payload xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns3:SmsMessage">
<ns3:fieldOne>true</ns3:DeliveryReports>
<ns3:fieldTwo xsi:type="ns3:hidden">
<ns3:fieldThree></ns3:ApplicationNumber>
</ns3:fieldTwo>
<ns3:SomeFiled xsi:type="ns3:hidden">
<ns3:number>123</ns3:number>
</ns3:SomeField>
<ns3:Content xsi:type="ns3:hidden">
<ns3:Text>String</ns3:Text>
</ns3:Content>
</Payload>
</Envelope>
</ns4:Pack>
</ns4:Send>
</S:Body>
</S:Envelope>
Thank you in advance

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

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.

Get values from a parsed XML Soap Message

I'm trying to consume a C# WCF Webservice with PHP, and I'm currently facing a really big problem.
First, let me show you what one of the the WCF Webservice responses looks like :
<?xml version="1.0" encoding="UTF-8"?>
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:header>
<activityid xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics" correlationid="6b8187a6-79a9-4bc4-a195-7c3b66547408">b340ad42-7be9-466c-a9f1-4048d35b7cb5</activityid>
</s:header>
<s:body>
<getalljobsresponse xmlns="http://tempuri.org/">
<getalljobsresult xmlns:a="http://schemas.datacontract.org/2004/07/Transcode.Webservice.Messages" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:jobinfo>
<a:associatedfilesize>34551192</a:associatedfilesize>
<a:associateduserid>10</a:associateduserid>
<a:jobcompletiondate>2016-06-09T10:37:42.2568136</a:jobcompletiondate>
<a:jobid>29</a:jobid>
<a:jobsubmissiondate>2016-06-09T10:37:27.8522463</a:jobsubmissiondate>
<a:remotefilepath>ftp://localhost/transcode_uploads/Luc/LinkinPark-DontStay.au</a:remotefilepath>
<a:taskprice>0.05</a:taskprice>
<a:taskstate>2</a:taskstate>
</a:jobinfo>
<a:jobinfo>
<a:associatedfilesize>34551192</a:associatedfilesize>
<a:associateduserid>10</a:associateduserid>
<a:jobcompletiondate>2016-06-09T11:46:07.7590635</a:jobcompletiondate>
<a:jobid>1029</a:jobid>
<a:jobsubmissiondate>2016-06-09T11:45:55.8115507</a:jobsubmissiondate>
<a:remotefilepath>ftp://localhost/transcode_uploads/Luc/LinkinPark-DontStay.au</a:remotefilepath>
<a:taskprice>0.05</a:taskprice>
<a:taskstate>2</a:taskstate>
</a:jobinfo>
</getalljobsresult>
</getalljobsresponse>
</s:body>
</s:envelope>
I'm trying everything to get a jobinfo element with all its attributes, but it doesn't seem to work well ...
I tried the following line of code :
$xml->getElementsByTagName('associatedfilesize')->item(0)->nodeValue
And it works on a single attribute, as for jobid or anything else !
The problem is, I would like to get a jobInfo objet in its entirety, by using something like :
$xml->getElementsByTagName('jobInfo')
Could you please help me guys, I have very little time left to finish my work and I'm stuck on that issue for too long...

Converting from XML to PHP

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

getting pure xml detail from soap xml response

i have a .net service i am consuming from php and the result comes in the format below.
i wish to have only the contents without the soap:envelope.
How do i achieve this?
<?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:Body><VAccResponse xmlns="http://apps.hbng.com/"><VAccResult><VAccountSummary><Id>C0000005</Id><AccountNo>5100000014</AccountNo><AccountName>xyz HOSPITAL LTD</AccountName><SchemeCode>abc</SchemeCode><SchemeDescription>abc records</SchemeDescription><Balance>6627282</Balance><CurrencyCode>DOLLARS</CurrencyCode><AccountManagerId>F05</AccountManagerId><Debit>0</Debit><Credit>0</Credit><Tran>NO TRANSACTION DONE</Tran></VAccountSummary></VAccResult></VAccResponse></soap:Body></soap:Envelope>
How do i get the xml result without the soap:body, soap envelope etc...

Categories