2

I am new to using SOAP to communicate with Web Services, I recently wrote a client in php to communicate with a Web Service but get this error message back:

"Error Response not of type text/xml: text/html"

Is there something wrong with the format I send away? Please find the request below:

Request

POST /MobileCashPayout.asmx HTTP/1.0
Host: www.mtn.com
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 971

<?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><ns5667:Payout xmlns:ns5667="http://tempuri.org"><__numeric_0 xsi:type="xsd:string">testmerc</__numeric_0><__numeric_1 xsi:type="xsd:string">testmerc</__numeric_1><__numeric_2 xsi:type="xsd:string">256750000005</__numeric_2><__numeric_3 xsi:type="xsd:string">256753986532</__numeric_3><__numeric_4 xsi:type="xsd:string">256750000005</__numeric_4><__numeric_5 xsi:type="xsd:string">100.00</__numeric_5><__numeric_6 xsi:type="xsd:string">2222</__numeric_6><__numeric_7 xsi:type="xsd:string"></__numeric_7><__numeric_8 xsi:type="xsd:string">BETNET</__numeric_8></ns5667:Payout></SOAP-ENV:Body></SOAP-ENV:Envelope>
SirBT
  • 1,580
  • 5
  • 22
  • 51
  • It looks like the response you are receiving is `html` rather than the expected `xml`. You could try posting your request through Fiddler so that you can examine the actual response, away from the constraints of your code. – Sir Crispalot Jul 16 '12 at 22:00
  • @Sir Crispalot Please tell me some more about Fiddler? Is it a browser plugin? or a php library? – SirBT Jul 16 '12 at 22:13
  • It's a piece of software that allows you to construct HTTP requests and see the raw responses. It also acts as a proxy so that you can pass all requests through it to examine them on the fly. http://www.fiddler2.com/fiddler2/. – Sir Crispalot Jul 16 '12 at 22:15

1 Answers1

1

You might want to try sending an "Accept: text/xml" header to inform the server that you are expecting an XML response.

Mike Brant
  • 70,514
  • 10
  • 99
  • 103
  • how do I do that? Can you demonstrate please? – SirBT Jul 16 '12 at 22:04
  • So I see you are using NuSOAP. Take a look at this StackOverflow item http://stackoverflow.com/questions/945922/nusoap-how-to-change-content-type-of-request Here there is an answer which hints that the SOAP protocol version you are using might be the problem the suggestion is to pass a config parameter at instantiation to use SOAP protocol 1.1 as most modern SOAP server client would expect to use content type of application/soap+xml. You might try using the native PHP SOAP implementation for better results. – Mike Brant Jul 16 '12 at 22:15
  • It seems like my Client only expects content type of text/xml, not of text/html nor applicatoin/soap+xml. So the suggestion to accept application/soap+xml unfortunately didnt seem to work... Any other suggestions are welcome – SirBT Jul 16 '12 at 22:53