I am trying to use curl to access the web service at http://www.carwebuk.com/carwebVRRB2B/CarweBVRRWebService.asmx?op=strB2BGetVehicleByVRM
Here is my code:
$url = "http://www.carwebuk.uk.com/carwebVRRB2B/CarweBVRRWebService.asmx/strB2BGetVehicleByVRM";
$post = "strUserName=string&strPassword=string&strClientRef=string&strClientDescription=string&strKey1=string&strVRM=string&strVersion string";
$header[] = "POST /carwebVRRB2B/CarweBVRRWebService.asmx/strB2BGetVehicleByVRM HTTP/1.1";
$header[] = "Host: www.carwebuk.uk.com";
$header[] = "Content-Type: application/x-www-form-urlencoded";
$header[] = "Content-Length: ".strlen($post);
$header[] = $post;
$ch = curl_init();
//curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
//curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $post); // add POST fields
$data = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
echo $data;
//returns <xml>...</xml>
Whhich just returns a error "Operation timed out with 0 out of -1 bytes received"
Tried sending the $post variables with CURLOPT_POSTFIELDS but this just results in "System.InvalidOperationException: Missing parameter: strVersion. at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection) at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request) at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() at System.Web.Services.Protocols.WebServiceHandler.Invoke() at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()"
Anyone any idear?