Skip to Content
avatar image
Former Member

PHP SoapClient LoginService.wsdl Invalid document structure

Hello,

I am struggling with B1WS-Soap. This is my Code:

<?php

error_reporting(E_ALL);

try {

    $client = new SoapClient("http://192.168.80.3/B1WS/WebReferences/LoginService.wsdl", array('trace' => 1,'soap_version' => SOAP_1_2));

  $options = array(

    'DatabaseServer' => '192.168.81.4',

    'DatabaseName' => 'SBODEMODE',

    'DatabaseType' => 'dst_MSSQL2012',

    'CompanyUsername' => 'manager',

    'CompanyPassword' => 'secret',

    'Language' => 'ln_German',

    'LicenseServer' => '192.168.81.3:30000',

  );

  $something = $client->Login($options);

  var_dump($something);

}catch (Exception $e) {

    echo "<pre>";

    print_r($e);

}

?>

This is the error:

SoapFault Object ( [message:protected] =&amp;gt; Invalid XML [string:Excepti - Pastebin.com

Somewhere I read there could be encoding issues... Can someone post demo-code? Thanks.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 03, 2015 at 11:03 PM

    Hi Kevin,

    the issue is indeed related to encoding.

    PHP adds encoding="UTF-8" in the xml declaration - DI Server cannot handle that.

    If you open your B1WSHandler.cs you will see the following lines :

     // Remove encoding="utf-8" => .NET adds it and DI Server doesn't accept it!
    int index = request.IndexOf("encoding=\"utf-");
    if (index > 0 && index < 50)
         request = request.Remove(index, 16);
    

    So, .NET is adding encoding="utf-8" and this is removed. You have to do the same for PHP.

    An easy workaround would be to change your B1WSHandler.cs to:

    int index = request.ToUpper().IndexOf("ENCODING=\"UTF-");
    if (index > 0 && index < 50)
       request = request.Remove(index, 16);
    

    regards,

    Maik

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Maik Delly

      Hi Maik,

      I tried both, SOAP and COM but I still get SOAPFaults:

      <pre><?xml version="1.0"?><env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><env:Fault><env:Code><env:Value>env:Receiver</env:Value><env:Subcode><env:Value>-10</env:Value></env:Subcode></env:Code><env:Detail><Command>Login</Command></env:Detail></env:Fault></env:Body></env:Envelope> 

      I don't know what I am doing wrong. DI does not respond with any error message so I could investigate what the issue could be.