在soap客户端php上创建一个对象

时间:2014-02-24 18:32:22

标签: php soap

我试图使用php中的soap库创建一个具有以下代码的新对象:

<?php
    try{
$wsdl="https://THE.IP.HERE:PORT/B1WS/WebReferences/LoginService.wsdl";
$client=new SoapClient($wsdl, array('location' => 'https://THE.IP.HERE:PORT/B1WS/Service.asmx', 'trace' => true));

var_dump($client);

echo "Types: -> ";
print_r($client->__getTypes());

echo "Functions: -> ";
var_dump($client->__getFunctions());

$res=$client->Login(array(
'DatabaseServer'   => 'THE.IP.HERE',
'DatabaseName'     => 'DATABASE_NAME',
'DatabaseType'     => 'dst_MSSQL2012',
'DatabaseUsername' => 'USERNAME',
'DatabasePassword' => 'DATABASE',
'CompanyUsername'  => 'USERNAME',
'CompanyPassword'  => '****',
'Language'         => 'ln_English',
'LicenseServer'    => 'THE.IP.HERE:30000'));
print_r($res);


echo htmlentities($client->__getLastRequest());

}
catch( SoapFault $e )
{

echo htmlentities($client->__getLastRequest());

print_r($e);
}
?>

我收到以下错误:

  

致命错误:在第40行的C:\ wamp \ www \ mysite.local \ teste.php中的非对象上调用成员函数__getLastRequest()

行回声htmlentities($ client-&gt; __ getLastRequest());在崇高的文本上。

我在我的php上激活了soap扩展程序。即时通讯使用php 5.4.12

任何人都可以帮忙解决这个问题吗?

三江源

1 个答案:

答案 0 :(得分:0)

所以,我把这个页面移到了一个在线服务器上,我已经可以在数组上得到一些信息..但我认为这不是我想要的。

object(SoapClient)#1 (4) {
  ["location"]=>
  string(42) "https://MY.IP:PORT/B1WS/Service.asmx"
  ["trace"]=>
  int(1)
  ["_soap_version"]=>
  int(1)
  ["sdl"]=>
  resource(2) of type (Unknown)
}


Types: ->
Array
(
    [0] => struct LoginResponse {
 string SessionID;
}
    [1] => struct LogoutResponse {
}
    [2] => struct MsgHeader {
 string SessionID;
}
    [3] => struct Login {
 string DatabaseServer;
 string DatabaseName;
 DatabaseType DatabaseType;
 string CompanyUsername;
 string CompanyPassword;
 Language Language;
 string LicenseServer;
}
    [4] => string DatabaseType
    [5] => string Language
    [6] => struct Logout {
}
)


Functions: -> array(4) { [0]=> string(38) "LoginResponse Login(Login $parameters)" [1]=> string(41) "LogoutResponse Logout(Logout $parameters)" [2]=> string(38) "LoginResponse Login(Login $parameters)" [3]=> string(41) "LogoutResponse Logout(Logout $parameters)" } 

<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="LoginService"><SOAP-ENV:Body><ns1:Login><ns1:DatabaseServer>MY.IP:PORT</ns1:DatabaseServer><ns1:DatabaseName>MYDATABASE</ns1:DatabaseName><ns1:DatabaseType>dst_MSSQL2012</ns1:DatabaseType><ns1:CompanyUsername>user</ns1:CompanyUsername><ns1:CompanyPassword>pass</ns1:CompanyPassword><ns1:Language>ln_English</ns1:Language><ns1:LicenseServer>MY.IP:30000</ns1:LicenseServer></ns1:Login></SOAP-ENV:Body></SOAP-ENV:Envelope> 

SoapFault Object
(
    [message:protected] => Invalid XML
    [string:Exception:private] => 
    [code:protected] => 0
    [file:protected] => /var/www/vhosts/domain.pt/httpdocs/teste.php
    [line:protected] => 45
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [file] => /var/www/vhosts/domain.pt/httpdocs/teste.php
                    [line] => 45
                    [function] => __call
                    [class] => SoapClient
                    [type] => ->
                    [args] => Array
                        (
                            [0] => Login
                            [1] => Array
                                (
                                    [0] => Array
                                        (
                                            [DatabaseServer] => MY.IP:PORT
                                            [DatabaseName] => MYDATABASE
                                            [DatabaseType] => dst_MSSQL2012
                                            [DatabaseUsername] => user
                                            [DatabasePassword] => pass
                                            [CompanyUsername] => companyuser
                                            [CompanyPassword] => companypass
                                            [Language] => ln_English
                                            [LicenseServer] => MY.IP:30000
                                        )

                                )

                        )

                )

            [1] => Array
                (
                    [file] => /var/www/vhosts/domain.pt/httpdocs/teste.php
                    [line] => 45
                    [function] => Login
                    [class] => SoapClient
                    [type] => ->
                    [args] => Array
                        (
                            [0] => Array
                                (
                                    [DatabaseServer] => MY.IP:PORT
                                    [DatabaseName] => MYDATABASE
                                    [DatabaseType] => dst_MSSQL2012
                                    [DatabaseUsername] => user
                                    [DatabasePassword] => pass
                                    [CompanyUsername] => companyuser
                                    [CompanyPassword] => companypass
                                    [Language] => companypass
                                    [LicenseServer] => MY.IP:30000
                                )

                        )

                )

        )

    [previous:Exception:private] => 
    [faultstring] => Invalid XML
    [faultcode] => env:Sender
    [detail] => stdClass Object
        (
            [ErrorList] => stdClass Object
                (
                    [Error] => System Id = 37574776, Line Number = 2, Column Number = 1, Description = Invalid document structure
                )

        )

)