简体   繁体   中英

Send XML to another server via POST

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM