Sending raw XML with php nusoap client

In my last blog post I described how to use wsdl2php to parse a wsdl file and generate php classes. This should make your life a lot simpler when dealing with SOAP Web Services.

But there are times that all the frameworks and toolkits in the world wont be able to produce the desired plain XML structure of the SOAP call. Especially when you are working with Chinese low-end equipment.

I usually work in php nusoap and I had trouble finding the right way to do this. I was so desperate, that I have been posting raw XML with CURL to mimic the SOAP Request. Luckily I found a way to do i with our favourite php soap toolkit.

Thow following is an example that calls a function insertUser with raw XML:


$endpoint = "";

$client = new nusoap_client($endpoint, false);

$msg = $client->serializeEnvelope("
<ns1:insertuser xmlns:1="">
  <arg0 xsi:type="xsd:string">name</arg0>
    <username xsi:type="xsd:string">username</username>
    <password xsi:type="xsd:string">0ac495f743a36cef9b0eaafa92ae08e21</password>
  <arg2 xsi:type="xsd:string">email</arg2>
  <arg3 xsi:type="xsd:string">domain</arg3>

$result=$client->send($msg, $endpoint);



  1. Could you please post a server example to the above code.

    1. What do you mean by a server example? I have usually used this when I have worked with predefined SOAP servers

  2. hi i m used the same code but i got error "Response not of type text/xml: text/html; charset=UTF-8" any idea why this occurred . i am using 3 party web services