I have a php script that is interacting with a .NET web service. I have multiple pieces that are calling different functions via soap with no issue so everything is working great.
PHP Version => 5.3.2-1ubuntu4.18
My new situation is a specific function that requires 4 parameters, all of type string, but one of which is an entire XML document.
When I look at the request I'm sending for this function, everything in the request looks great except the xml, which is encoded (all the opening and closing brackets).
It seems like there should be a strait forward way to deal with this but nothing is coming up on the net. I have tried SoapClient options and escaping but nothing is changing this.
Here is the XML being fed to the SoapClient:
<Setup>
<CustomerAccount>xxxx24838</CustomerAccount>
<MasterSource enumType="MasterSource">3</MasterSource>
<MasterReceived enumType="YesNo">1</MasterReceived>
<AID>kjsdlkfjsldkfj334</AID>
</Setup>
Here is the request being sent:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.xxxxxxx.com/">
<SOAP-ENV:Body>
<ns1:Save>
<ns1:objectName>CASetup</ns1:objectName>
<ns1:xmlData>
<Setup><CustomerAccount>xxxx24838</CustomerAccount>
<MasterSource enumType="MasterSource">3</MasterSource>
<MasterReceived enumType="YesNo">1</MasterReceived>
<AID>kjsdlkfjsldkfj334</AID>
</Setup>
</ns1:xmlData>
<ns1:operation>saveMasterAsReceived</ns1:operation>
<ns1:Brand>6</ns1:Brand>
</ns1:Save>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I have formatted just for ease of reading.
Related
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 !
I'm dealing with an incredibly bad API that requires me to send this XML:
<?xml_version string(335) ""1.0" encoding="utf-16"?>
<GetTicketAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CompanyName>*name*</CompanyName>
<IntegrationLoginId>*id*</IntegrationLoginId>
<IntegrationPassword>*password*</IntegrationPassword>
<SrServiceRecid>*recordId*</SrServiceRecid>
</GetTicketAction>
via POST (as actionString) to a server that is not under my control. I've tried it with JavaScript (couldn't, cross scripting) and with CURL (got "this needs to be encrypted error"). Encryption is not mentioned anywhere in the docs, which say that it can be done with JS in IE using "full trust."
Content type is application/x-www-form-urlencoded if that helps.
Is there any way to send this with either JS and/or PHP?
After many painful years of this API slowly driving me insane, I discovered that it did NOT want me to send the XML through the standard CURL pattern of
$data = array(
"actionString" => $xml
);
Rather, I was to do:
$data = 'actionString=<?xml_version string(335) ""1.0" encoding="utf-16"?>
<GetTicketAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CompanyName>*name*</CompanyName>
<IntegrationLoginId>*id*</IntegrationLoginId>
<IntegrationPassword>*password*</IntegrationPassword>
<SrServiceRecid>*recordId*</SrServiceRecid>
</GetTicketAction>'
Future API writers: Let this be a warning. I'm really hoping a crazed psychopath knows where this guy sleeps.
I need to send a file to a web service (ebridge) using their SendFile method. This may be too specific to their service for anyone to answer, but I thought I'd give it a try. This is the only documentation I can find regarding the SendFile method:
Purpose
This method is used to submit data for processing by ePortal.
Input parameters
Login (string) The ePortal userID.
Password (string) The ePortal password for that user.
Content (string) This is the document to be uploaded.
Filename (string) This is the name of the file with no path information.
Return Value
SendFileResult (boolean) The boolean return value represents success or failure of the submission of a document.
Here is their sample xml code for posting:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SendFile xmlns="eBridge.WebServices">
<login>mylogin</login>
<password>mypassword</password>
<content>string</content>
<filename>string</filename>
</SendFile>
</soap:Body>
</soap:Envelope>
I am also given a sample of the file (ASN.xml) that I am supposed to send. I've tried putting the xml from this file in between the content tags and just putting "test.xml" in the filename tags. That doesn't work. I know I am making a connection because if I leave it just like it is above I will get a response back, it just returns false since I didn't send anything. Perhaps I am misunderstanding what they want in content and filename? Does anyone have any ideas what I am supposed to do with this?
clarification: What I am wondering is if the xml file goes into 'content' as a string, then what is 'filename' for? Is it actually looking for a file or is this just a name that gets assigned to something later?
Ummm, are you creating a SOAPClient? That xml file is actually the body of a SOAP request and that is encapsulated by the SOAPClient class in PHP.
For the WSDL file: https://www.ebridgeservices.com/ePortalService.asmx?WSDL
Use the SOAPClient Class to build your request to their services. Use $soapReq->SendFile({args and blah here})
and if you don't like the PHP Manual: Here's an example/tutorial.
Their web page has a "live chat". Why don't you ask them?
http://www.ebridgeconnections.com/support/development-kit/API-services.html
But I believe <content> means exactly that: you're supposed to include the entire XML file - as a string - in the SOAP message.
IMHO...
I'm using Zend_Soap_Client object for sending a soap request to another application here is the format of the XML that it's sending to the server:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urllocation" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://www.w3.org/2003/05/soap-encoding"><env:Body><ns1:isAccountActive env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"><param0 xsi:type="xsd:string">thisisatest</param0></ns1:isAccountActive></env:Body></env:Envelope>
I'm using it on the other SOAP servers that I have and seems to work fine but one of the server returned a response "Invalid XML" that is why I'm really wondering why it won't work on that server alone. Any ideas would be greatly appreciated.
Additional Details:
I've tried to commentout the code that calls the method from the Server here is the code:
$client = new Zend_Soap_Client(null,
array(
'uri'=>'http://'.$user->customconfigs['alumniuri'],
'encoding'=>'UTF-8',
'location'=>'http://'.$user->customconfigs['alumnilocation']
)
);
echo "Location: {$user->customconfigs['alumnilocation']} - uri: {$user->customconfigs['alumniuri']}";
$alumniactive = $client->isAccountActive($token);
upon commenting out:
$alumniactive = $client->isAccountActive($token);
the error disappeared.This is the same codes from my other applications and it's working fine from there.
After a long search for the answer to this question I finally found the problem... this code is actually located on a joomla component which I was using the uri same as what I have from the location that would include a character "&" which is illegal on xml standards removing these character from my xml will then cause the SOAP server to accept the request as valid. :)
I am working on building a web service in PHP using the SoapServer class, but I'm running into an issue with casting of complex types.
The WSDL is completely valid, and the PHP SoapClient handles it flawlessly, but there seems to be an issue with the complex types that are returned not being cast properly. This came to light when consuming the service in .Net, as I was getting exceptions that indicated the type was not present in the given namespace.
I mangled my function numerous times, changing the namespace on the element, but .Net continues to give me errors, regardless of what namespace I use.
Consider the following abbreviation of the script:
function getCommands() {
$output = array();
// ...
foreach($result as $row) {
$output[] = new SoapVar($row, SOAP_ENC_OBJECT, 'ns1:command');
}
return $output;
}
The abbreviated response:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:MyWebService"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getCommandsResponse>
<return SOAP-ENC:arrayType="ns1:command[12]" xsi:type="ns1:ArrayOfCommand">
<item xsi:type="ns1:command">
<!-- ... -->
</item>
<!-- ... -->
</return>
</ns1:getCommandsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
What I've noticed is that xmlns:ns1 is defined by way of the WSDL, and it does match the namespace in the WSDL. However, the .Net SOAP client doesn't seem to understand that the command element is defined there. It does, however, understand that that's where ArrayOfCommand is defined.
So my question is multipart:
Is this a known bug with the SoapServer?
If not, am I missing something grievous in my WSDL?
Am I not encoding my objects properly?
Is this an issue with .Net? If so, what's the work-around?
I was able to resolve this issue by working over the <types/> section of my WSDL again, using the Google WSDL for reference. Then, I had to work some magic in my PHP function, casting the elements of the $command appropriate to their respective types in the WSDL, and encoding the entire command as a ns2:command. When aligned with the WSDL, this all fell together nicely and .Net is having zero difficulty with it.
I'm surprised nobody in the development community was willing to answer this, but I hope someone will be able to glean from it at least some direction on how to fix their own instance of this problem.