Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

How do I resolve the following error from a .NET Soap Server when using PHP SoapClient to access it?

Server was unable to process request. ---> 
There was an error executing a remote action 
(There was an error deserializing an object 
(There is an error in XML document (1, 2). 
(<HTML xmlns=''> was not expected.)))

Trace is on and getlastrequest is:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://my.wsdl.domain/">
<SOAP-ENV:Body><ns1:CreateAccount>
<ns1:parameters>
<ns1:NameValue><ns1:name>name1</ns1:name>
<ns1:value>value1</ns1:value></ns1:NameValue>
<ns1:NameValue><ns1:name>name2</ns1:name>
<ns1:value>value2</ns1:value></ns1:NameValue>
</ns1:parameters>
</ns1:CreateAccount>
</SOAP-ENV:Body></SOAP-ENV:Envelope>

getlastresponse is:

<?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><soap:Fault><faultcode>soap:Server</faultcode>
<faultstring>Server was unable to process request. ---&gt; 
There was an error executing a remote action 
(There was an error deserializing an object 
(There is an error in XML document (1, 2). 
(&lt;HTML xmlns=''&gt; was not expected.)))
</faultstring><detail /></soap:Fault>
</soap:Body></soap:Envelope>

I don't have access to the vendor's soap server.

Here is the PHP client code:

<?php

    class CreateAccount {
      public $parameters; // ArrayOfNameValue
    }

    class AccountService extends SoapClient {

      private static $classmap = array(
                                        'CreateAccount' => 'CreateAccount',
                                        'NameValue' => 'NameValue');

       public function AccountService($wsdl = 
"https://my.wsdl.domain/myservice.asmx?wsdl", $options = array("trace" => 1)) {
        foreach(self::$classmap as $key => $value) {
          if(!isset($options['classmap'][$key])) {
            $options['classmap'][$key] = $value;
          }
        };
        parent::__construct($wsdl, $options);

        }

      public function CreateAccount(CreateAccount $parameters) {
        return $this->__soapCall('CreateAccount', array($parameters),       array(
                'uri' => 'https://ws.my.wsdl.domain/',
                'soapaction' => ''
               )
          );
      }

    } //class

    $account = new AccountService();


    // create new account
    $create = new CreateAccount();
    $create->parameters = array();

    $NameValue1 = new NameValue();
    $NameValue1->name = "NameValue1";
    $NameValue1->value = "NameValue1";
    $create->parameters[] = $NameValue1;

    $NameValue2 = new NameValue();
    $NameValue2->name = "NameValue2";
    $NameValue2->value = "NameValue2";
    $create->parameters[] = $NameValue2;

    try {
    $cr_result = $account->CreateAccount($create);
    } catch (SoapFault $exception) {
        echo $exception->getMessage()."\n\n";
    }

    //dbg
    echo "Request:  " . $account->__getLastRequest()."\n\n"; 
    //echo "Requestheaders:  " . $account->__getLastRequestHeaders()."\n"; 
    echo "Response:  " . $account->__getLastResponse()."\n\n";  
    //echo "Responseheaders:  " . $account->__getLastResponseHeaders()."\n"; 
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.