cancel
Showing results for 
Search instead for 
Did you mean: 

PHP SoapClient LoginService.wsdl Invalid document structure

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

maik_delly
Active Contributor
0 Kudos

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

maik_delly
Active Contributor
0 Kudos

Btw : you can nicely debug B1WSHandler.cs using Visual Studio, just attach to the w3wp.exe process ( the one that is running with username AppPool4B1WS ).

Former Member
0 Kudos

Wow, thank you. I will try this later today and give feedback. I am a PHP-developer and we just switched to SAP. The B1WS look very promising but I don't find any docs. Did I miss them or do I need to browse the code to get more information?

maik_delly
Active Contributor
0 Kudos

Well, welcome to Business One SDK world.

I don't know what you have to realize but it will be quite hard using PHP - simply because SBO SDK is ( so far )  a .NET dominated topic. Of course you can use PHP for SOAP based communicating with DI Server ( as almost all languages ) but imho it will be a litte bit harder for you. There is only little to no documentation for using B1WS - mainly because it is "standard" SOAP .

You will find some examples in this forum and you have to build your knowledge from that. In the end you just have to get the trick once.

I did my share with PHP and nowadays whenever I have to realize something for web I use a .NET webservice to interact with B1WS. That way I can profit from the .NET WSDL proxy prospects (OOP) and debugging is imho a lot easier.

HTML/JS/AJAX/PHP...  -> .NET webservice -> B1WS/DIS -> SBO

If you don't have any experience with .NET then of course it is ridiculous to tell you to learn it..

The more I think about it, I would suggest to send "ready made" xml to DI Server ( via SBODI_Server.Node ). I never tried, but maybe you can access it using PHP directly - this way you "just" have to handle xml data.

regards,

Maik

maik_delly
Active Contributor
0 Kudos

Out of curiosity I tried and it seems to work like a charm :


<?php

error_reporting(E_ALL);

if (isset($_POST['BO_XML']))

{

    try

    {

        echo "<pre>";

        $myDIS = new COM("SBODI_Server.Node") or die("Error : Could not get DIS COM Object");

      

        echo $myDIS->Interact($_POST['BO_XML']);

    }

    catch (Exception $e)

    {

        print_r($e);

    }

}

else

{

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>

    <title>DIS Node PHP Test</title>

  </head>

  <body>

    <h1>Please enter XML :</h1><br>

    <form method="post">

        <textarea name="BO_XML" style="width: 600px; height: 220px;"><?xml version="1.0" encoding="UTF-16"?>

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">

  <env:Body>

    <dis:Login xmlns:dis="http://www.sap.com/SBO/DIS">

      <DatabaseServer>server</DatabaseServer>

      <DatabaseName>SBODemoDE</DatabaseName>

      <DatabaseType>dst_MSSQL2012</DatabaseType>

      <CompanyUsername>manager</CompanyUsername>

      <CompanyPassword>password</CompanyPassword>

      <Language>ln_English</Language>

      <LicenseServer>server:30000</LicenseServer>

    </dis:Login>

  </env:Body>

</env:Envelope></textarea>

        <br><br>

        <input type="submit" name="send">

    </form>

  </body>

</html>

<?php

}?>

This would make B1WS unnecessary and instead of building ( complicated ) SOAP messages, you could send DIS messages directly ( pure XML ).

regards,

Maik

Former Member
0 Kudos

Hi Maik,

just had the time to check the code you posted.

I fixed MSSQL 2014 using your description in:

http://scn.sap.com/thread/3676382

Now I receive:


[previous:Exception:private] =>
[faultstring] => The TAO NT Naming Service has stopped
[faultcode] => env:Receiver
[detail] => stdClass Object
    (
        [Command] => Login
    )

TAO NT Naming Service is started and working fine as the SAP-Client / SLD does not show any errors. We just migrated from B1 9.0 on SQL 2012 to B1 9.1PL4 on SQL 2014.

Any ideas would be appreciated, thank you!

maik_delly
Active Contributor
0 Kudos

Hi Kevin,

since this error can occur when IP settings change ( DHCP ) my first idea would be to make a restart ( IT rule no 1 reboot is good ).

Then make sure to use same license server information used in SBO service manager ( IP vs host name ). If it is not the same machine, turn off all firewalls to verify that they are not causing this issue. 

In general this error is stating that license information can not be accessed.

regards,

Maik

Former Member
0 Kudos

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.

Answers (0)