开发者

PHP nuSoap issue when connecting to a .NET server: "Object reference not set to an instance of an object."

I am currently working on a SOAP project using PHP. The script is connecting to a remote .NET service server. I get a nice response using the HelloWorld action the provide, but when the script goes to get any other data using other actions, I get

"Object reference not set to an instance of an object."

in a diffgram sub array of the $data array (see below).


Here is the current code, excluding the service URLs and params.

<?php

require_once('../lib/nusoap.php');

$options = array(

    # server

    'wsdl'  => false,
    'srvr'  => 'http://test.domain.com/soap/file.asmx',

    'base'  => 'http://sub.domain.com/',
    'act'   => isset($_POST['act'])     ? $_POST['act']     : 'RequestSomething',

    'curl'  => isset($_POST['curl'])    ? $_POST['curl']    : false,
    'char'  => 'UTF-8',

    # proxy

    'host'  => isset($_POST['host'])    ? $_POST['host']    : false,
    'port'  => isset($_POST['port'])    ? $_POST['port']    : false,
    'user'  => isset($_POST['user'])    ? $_POST['user']    : false,
    'pass'  => isset($_POST['pass'])    ? $_POST['pass']    : false,

);

$client = new nusoap_client(

    $options['srvr'],       $options['wsdl'],

    $options['host'],       $options['port'],       $options['user'],       $options['pass']

);

$client->soap_defencoding = $options['char']; 

$client->setUseCurl($options['curl']);

$error = $client->getError();

if($error){

    $debug = htmlspecialchars($client->getDebug(), ENT_QUOTES);

    echo "<h2>Error</h2><pre>$error</pre&开发者_StackOverflow社区gt;";

    echo "<h2>Debug</h2><pre>$debug</pre>";

    exit;
}

$params = array(

    'ID' => 123,
);

$send = $params;

$do = $options['base'] . $options['act'];

$data = $client->call($options['act'], $send, $do, $do);    

if($data && $data = (array) $data) {
    echo "<h2>Call data</h2>";
    echo "<pre>" .  print_r($data,true) . "</pre>";
}
?>


Try soapUI (there's a free version) or another similar SOAP test client and make sure that the web service you're consuming actually works as expected. If it does, then worry about your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜