I'm new to SOAP and I'm having issues (yes, I have searched - extensively, but I can't seem to match my very simple requirement - sending a single XML string) with sending some output to a .NET server to match this:
POST /someurl.asmx HTTP/1.1
Host: www.somehost.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://somehost.com/SubmitCalls"
<?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>
<SubmitCalls xmlns="http://somehost/">
<request>string</request>
</SubmitCalls>
</soap:Body>
</soap:Envelope>
My nusoap code looks like this:
<?php
require_once('../lib/nusoap.php');
$bodyxml = '<?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>
<SubmitCalls xmlns="http://somehost/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<request>
<?xml version="1.0" encoding="UTF-8"?>
<bXML xmlns="http://somehost/Schemas" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<From>
<UserName>some username</UserName>
<Password>some password</Password>
</From>
<Calls>
<Call>
<Reference>11111</Reference>
<Name>Joe Bloggs</Name>
<Tel1>02075574200</Tel1>
<Tel2>02075574201</Tel2>
<Tel3>02075574202</Tel3>
<Tel4>02075574203</Tel4>
<Tel5>02075574204</Tel5>
<CLI>08448220640</CLI>
<CallTime>09:00</CallTime>
<FileName>02075574200_1</FileName>
</Call>
<Call>
<Reference>11111</Reference>
<Name>Joe Bloggs</Name>
<Tel1>02075574200</Tel1>
<Tel2>02075574206</Tel2>
<Tel3>02075574207</Tel3>
<Tel4>02075574208</Tel4>
<Tel5>02075574209</Tel5>
<CLI>08448220640</CLI>
<CallTime>09:00</CallTime>
<FileName>02075574200_2</FileName>
</Call>
</Calls>
</bXML>
</request>
</SubmitCalls>
</soap:Body>
</soap:Envelope>
';
$client = new nusoap_client("somehost?WSDL",true);
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
exit();
}
$client->soap_defencoding = 'utf-8';
$client->useHTTPPersistentConnection();
$client->setUseCurl($useCURL);
$bsoapaction = "http://somehost/SubmitCalls";
$result = $client->send($bodyxml, $bsoapaction);
// Check for a fault
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
}
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Client Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
echo '<h2>Proxy Debug</h2><pre>' . htmlspecialchars($proxy->debug_str, ENT_QUOTES) . '</pre>';
?>
(Obiously, all the somehost and usernames are correct in the final script). I can connect to the WSDL, read it, there's only one method I'm interested in (SubmitCalls) which only has one part, named 'parameters' in the WSDL schema. The above throws a 400 Bad request error - any ideas where I'm going wrong?
I've tried using PHP SOAP instead, but I simply can't seem to send an XML string as the body of the SOAP request. I've been fiddling with this for the best part of three days and read a zillion web pages, but I still can't get it right. Please help.... if you could show me how to do this using either library I would be enormously grateful....