Replacing SOAP headers in PHP - php

I need to use soap to get some informations from one of our providers. They gave us the url to call and then left us pretty much in the dark. After searching we understood that the headers they use are different from the standard ones.
We need to send
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/"
xmlns:com="http://schemas.datacontract.org/2004/07/Commun.Interfaces.Request">
<soapenv:Header/>
<soapenv:Body>
So we tried to replace the regular header in the XML document by this one. It works, if we plint it before send it looks good.
But after sending we receive an exception :
looks like we got no XML document
and $soap->__getLastRequest() returns :
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body>
The replace has been lost. We tried to send it with CURL also, modifying the XPL before, and the same exception shows up. So we don't really know what to do.
Thanks ahead for any help !

Related

How can I format a PHP array that uses elements and attributes?

I am trying to send a SOAP request via PHP and while I am able to send via SOAPUI, I am having an issue formatting in PHP. The schema, located here shows an attribute embedded in the routePartitionName element which is where my code is falling apart. I need to send the pattern and routePartitionName in my array. Here is part of the SOAP request that is working:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.cisco.com/AXL/API/12.5">
<soapenv:Header/>
<soapenv:Body>
<ns:getLine sequence="?">
<pattern>6304389152</pattern>
<routePartitionName uuid="{BE888889-7C30-4C89-0CC4 C99FDE1025A9}">NA_DID_XLATE_PT</routePartitionName>
<returnedTags uuid="?">
.....
.....
</returnedTags>
Here is what I am sending in PHP that does not work:
$lineinfo = array("routePartitionName"=>"uuid={BE888889-7C30-4C89-0CC4-C99FDE1025A9}",
"pattern"=>"6304389152");
The logs show `[soapenv:Server] Item not valid: The specified uuid={BE888889-7C30-4C89-0CC4-C99FDE1025A9} was not found `
Can someone let me know what I am missing here?
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.

eBay API GeteBayDetails request returns 'no password and no token' error

I am trying to make a GeteBayDetails request to the Trading API so that I can find the acceptable values fields in an bulk AddFixedPriceItem call using the lms. I am doing a HTTP Post request using curl.
So I am sending the request to the following URL
https://api.sandbox.ebay.com/ws/api.dll
Headers that I am using are :
X-EBAY-API-COMPATIBILITY-LEVEL: 800
X-EBAY-API-SITEID: 3
X-EBAY-API-DEV-NAME: dev_key_here
X-EBAY-API-APP-NAME: App_key_here
X-EBAY-API-CERT-NAME: Cert_name_here
X-EBAY-API-CALL-NAME: GeteBayDetails
X-EBAY-API-DETAIL-LEVEL: 0
Request body
<?xml version="1.0" encoding="utf-8"?>
<GeteBayDetailsRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequestToken>My_Sandbox_user_token</RequestToken>
<RequestPassword>my_sandbox_user_password</RequestPassword>
<DetailName>ShippingServiceDetails</DetailName></GeteBayDetailsRequest>
Response
<?xml version="1.0" encoding="UTF-8"?>
<GeteBayDetailsResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2014-02-14T14:15:50.792Z</Timestamp>
<Ack>Failure</Ack>
<Errors><ShortMessage>No password and no token.</ShortMessage>
<LongMessage>No XML <RequestPassword> or <RequestToken> was found in XML Request.</LongMessage>
<ErrorCode>930</ErrorCode>
<SeverityCode>Error</SeverityCode>
<ErrorClassification>RequestError</ErrorClassification>
</Errors>
<Version>855</Version>
<Build>E855_INTL_API_16631620_R1</Build>
</GeteBayDetailsResponse>
I dont understand why its asking for a RequestPassword and RequestToken. I added these into the body, but the API seems to ignore them.
Also API's documentation doesn't seem to suggest that I need to use them and I'm not asking for user specific details. Anyone know what's going on? Any suggestions are welcome.
Thank you
You want to enclose your sandbox token in eBayAuthToken tags within the RequesterCredentials XML tags. So like this
<RequesterCredentials>
<eBayAuthToken> Your token here </eBayAuthToken>
</RequesterCredentials>
That should fix your problem. Make sure you remove the authorisation tags you have that are not working
I believe you can also omit the
<RequesterCredentials>
<eBayAuthToken> Your token here </eBayAuthToken>
</RequesterCredentials>
from the body/content of the request and instead put
"X-EBAY-API-IAF-TOKEN": "Y0uRAcCe$$T0k3n"
in the request header.

How can I get SoapUI request to work on a webserver

I would like it so customers don't have to travel off site to see their tracking info:(In other words they can track their shipment from my website) http://www.echo.com/ShipmentTracking/EchoShipmentTrack.aspx
I received the API documentation and I was able to test a remote API with SOAPUI successfully. I see that it has several tools to generating code for things like Java. I looked for a SoapUI to PHP tool but was unable to find one. I'm very new to PHP, could anyone give the code of how I could translate this XML into something that I could execute on a web server?
WSDL link: http://api.echo.com/Echo.API.ShipmentStatus/ShipmentStatusService.svc?wsdl
Sample Request generated by SOAPUI:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://api.echo.com/shipmentstatus/contracts/2012/02/" xmlns:ns1="http://api.echo.com/common/schemas/2012/02/" xmlns:ns2="http://api.echo.com/shipmentstatus/schemas/2012/02/">
<soapenv:Header/>
<soapenv:Body>
<ns:GetStatus>
<ns:getStatusRequest>
<ns1:UserCredentials>
<ns1:APIKey>------REMOVED-----</ns1:APIKey>
</ns1:UserCredentials>
<ns2:BatchProcessingOptions>
<ns1:NotificationOptions>
<ns1:NotifyByEmail>false</ns1:NotifyByEmail>
<ns1:NotifyEmail>dchol#echo.com</ns1:NotifyEmail>
</ns1:NotificationOptions>
<ns1:ShouldPartialProcessBatch>false</ns1:ShouldPartialProcessBatch>
<ns2:CostResultFormat>DETAIL</ns2:CostResultFormat>
<ns2:IncludeCostDetails>false</ns2:IncludeCostDetails>
<ns2:StatusResultFormat>DETAIL</ns2:StatusResultFormat>
</ns2:BatchProcessingOptions>
<ns2:ShipmentIdentifiers>
<ns1:ShipmentIdentifier>
<ns1:ShipmentAccountNumber>E9704</ns1:ShipmentAccountNumber>
<ns1:ShipmentNumber>17596853</ns1:ShipmentNumber>
</ns1:ShipmentIdentifier>
</ns2:ShipmentIdentifiers>
</ns:getStatusRequest>
</ns:GetStatus>
</soapenv:Body>
</soapenv:Envelope>
This question already have a solutions at stackoverflow.
Look at this answers:
https://stackoverflow.com/a/10505172/2324993
https://stackoverflow.com/a/1656763/2324993

JiBX/PiBX SOAP binding example

I was trying to find some examples how to write binding.xml with JiBX/PiBX for following SOAP response but with no luck. Does anyone know how to do this?
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns6:getDataResp xmlns:ns6="http://domain.com/response/data/">
<s3:requestId xmlns:s3="http://domain.com/entity/">12</s3:requestId>
<s4:errorCode xmlns:s3="http://domain.com/entity1/">0</s4:errorCode>
<ns6:dataResp>
<ns5:Data>Some string data</ns5:Data>
</ns6:dataResp>
</ns6:getDataResp>
</soapenv:Body>
</soapenv:Envelope>
If you are using JiBX you're in luck. You have a couple of options:
The apache cxf project has a databinding module for JiBX. You can use one of the open-source web servers such as servicemix to do your SOAP handling. This means you only have to bind the message schema (getDataResp in your example) with JiBX. You can find a nice example, here.
JiBX has it's own web server called JiBX/WS. It will also do all the SOAP handling for you.
I hope this helps!
Don
JiBX contributor

Categories