Hello, I am new to web services and have been trying to get an XML request to work. Here is a sample request the client has provided for me
<?xml version="1.0" encoding="ISO-8859-1"?>
<GErmH_Request
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="GErmH_Requests.xsd">
<CustomerRequests>
<Customer id="9999">
<Name>Customer Name</Name>
</Customer>
<Customer id="8888">
<Name>Customer Name 2Name>
</Customer>
</CustomerRequests>
</GErmH_Request>
They provided a C# application that connects to their server and you can paste in the request and it returns some customer information. My mission is to get it working in PHP. I tried some methods and am now using NuSOAP
<?
$client = new soapclient("http://mywebserviceURL.aspx", false,
$proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
// This is an archaic parameter list
$params = array("CustomerRequests" => array(
'Customer' => array('id' => '9999',
'name' => 'customer name')
));
$result = $client->call('GErmH_Request', $params, '', 'http://tempuri.org/EBillEPay_Request');
if ($client->fault) {
echo '<h2>Fault (This is expected)</h2><pre>'; print_r($result); echo '</pre>';
} else {
$err = $client->getError();
if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
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>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
?>
NuSoap creates this request
POST /WS_EBillEPay/wsEBillEPay.asmx HTTP/1.0
Host: www.acornmhl.com
User-Agent: NuSOAP/0.7.2 (1.94)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: "http://tempuri.org/EBillEPay_Request"
Content-Length: 700
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 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/"><SOAP-ENV:Body><GErmH_Request
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="GErmH_Requests.xsd"><CustomerRequests><Customer><id xsi:type="xsd:string">9999</id><name xsi:type="xsd:string">Customer Name</name></Customer></CustomerRequests></GErmH_Request></SOAP-ENV:Body></SOAP-ENV:Envelope>
This is the response that I recieve
HTTP/1.1 200 OK
Connection: close
Content-Length: 440
Date: Mon, 21 Aug 2006 21:01:58 GMT
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/5.1
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Set-Cookie: ASP.NET_SessionId=jtephu55rhk1aim0wdshnyay; path=/
Cache-Control: private, max-age=0
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><EBillEPay_RequestResponse xmlns="http://tempuri.org/"><EBillEPay_RequestResult>Failed Validation
Failed Server Validation
Empty XML string
</EBillEPay_RequestResult></EBillEPay_RequestResponse></soap:Body></soap:Envelope>
Just says "Failed Server Validation"
Grrr...!
If anyone can make heads or tails here is the C# code that is working
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
//
// This source code was auto-generated by Microsoft.VSDesigner, Version 1.1.4322.2032.
//
namespace TestClient01.com.example.www {
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protocols;
using System.ComponentModel;
using System.Web.Services;
/// <remarks/>
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="wsEBillEPaySoap", Namespace="http://tempuri.org/")]
public class wsEBillEPay : System.Web.Services.Protocols.SoapHttpClientProtocol {
/// <remarks/>
public wsEBillEPay() {
this.Url = "http://mywebserviceURL.aspx";
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/EBillEPay_Request",
RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string EBillEPay_Request(string sRequest) {
object[] results = this.Invoke("EBillEPay_Request", new object[] {
sRequest});
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginEBillEPay_Request(string sRequest, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("EBillEPay_Request", new object[] {
sRequest}, callback, asyncState);
}
/// <remarks/>
public string EndEBillEPay_Request(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((string)(results[0]));
}
}
}