这几天在做一个php调用webservice接口,头都弄晕了,还是不行,下面是调用代码.
////////////////////////////////////////////////////////////////////
include_once('nusoap/lib/nusoap.php');
// 创建一个soapclient对象,参数是server的WSDL 
$client = new soapclient('http://localhost:81/soap.php?wsdl',true);
// 参数转为数组形式传递
//$aryPara2 = array('user'=>'123','pwd'=>'311');
// 调用远程函数
$aryResult2 = $client->call('login',array($aryPara2));
////////////////////////////////////////////////////////////////////当程序执行到 $client->call('login',array($aryPara2));这个地方的时候,就跟执行死循环一样,状态栏从1%-38%,一直在运行,当页面超时后,出现下列错误(这些错误程序用函数显示的).Error
wsdl error: HTTP ERROR: Couldn't open socket connection to server http://localhost:81/soap.php?wsdl, Error (110): Connection timed out
RequestResponseDebug
2008-07-31 11:31:32.194111 soapclient: ctor wsdl=1 timeout=0 response_timeout=30
endpoint=string(50) "http://localhost:81/soap.php?wsdl"
2008-07-31 11:31:32.194253 soapclient: will use lazy evaluation of wsdl from http://localhost:81/soap.php?wsdl
2008-07-31 11:31:32.194305 soapclient: call: operation=wf_dianbo_check, namespace=http://tempuri.org, soapAction=, rpcParams=, style=rpc, use=encoded, endpointType=wsdl
params=array(1) {
  [0]=>
  array(2) {
    ["mobile"]=>
    string(11) "13755765033"
    ["message"]=>
    string(1) "3"
  }
}
headers=bool(false)
2008-07-31 11:31:32.194367 soapclient: instantiating wsdl class with doc: http://localhost:81/soap.php?wsdl
2008-07-31 11:31:32.194452 wsdl: ctor wsdl= timeout=0 response_timeout=30
2008-07-31 11:31:32.194499 wsdl: parse and process WSDL path=
2008-07-31 11:31:32.194553 wsdl: setCredentials username= authtype= certRequest=
array(0) {
}
2008-07-31 11:31:32.194593 wsdl: parse and process WSDL path=http://localhost:81/soap.php?wsdl
2008-07-31 11:31:32.194626 wsdl: parse WSDL at path=http://localhost:81/soap.php?wsdl
2008-07-31 11:31:32.194663 wsdl: getting WSDL http(s) URL http://localhost:81/soap.php?wsdl?wsdl
2008-07-31 11:31:32.194738 soap_transport_http: ctor url=http://localhost:81/soap.php?wsdl?wsdl use_curl= curl_options:
array(0) {
}
2008-07-31 11:31:32.194784 soap_transport_http: parsed URL scheme = http
2008-07-31 11:31:32.194818 soap_transport_http: parsed URL host = localhost:81
2008-07-31 11:31:32.194848 soap_transport_http: parsed URL path = /soap.php
2008-07-31 11:31:32.194879 soap_transport_http: parsed URL query = wsdl
2008-07-31 11:31:32.194917 soap_transport_http: set header Host: localhost
2008-07-31 11:31:32.194990 soap_transport_http: set header User-Agent: NuSOAP/0.7.3 (1.114)
2008-07-31 11:31:32.195032 soap_transport_http: set header Accept-Encoding: gzip, deflate
2008-07-31 11:31:32.195067 soap_transport_http: set header Connection: close
2008-07-31 11:31:32.195103 soap_transport_http: entered send() with data of length: 0
2008-07-31 11:31:32.195141 soap_transport_http: connect connection_timeout 0, response_timeout 30, scheme http, host localhost, port 80
2008-07-31 11:31:32.195189 soap_transport_http: calling fsockopen with host localhost:81 connection_timeout 0
2008-07-31 11:32:32.192287 soap_transport_http: Couldn't open socket connection to server http://localhost:81/soap.php?wsdl?wsdl, Error (110): Connection timed out
2008-07-31 11:32:32.192372 wsdl: HTTP ERROR: Couldn't open socket connection to server http://localhost:81/soap.php?wsdl?wsdl, Error (110): Connection timed out
2008-07-31 11:32:32.192445 soapclient: checkWSDL
2008-07-31 11:32:32.192481 soapclient: got wsdl error: HTTP ERROR: Couldn't open socket connection to server http://localhost:81/soap.php?wsdl, Error (110): Connection timed out

解决方案 »

  1.   

    你的 webservice 是开放在 localhost 的 81 端口上?
    用其他工具测试一下 webservice 是不是能够正确访问。
      

  2.   

    是的,请问其它工具是哪些工具?
    程序这样调用没问题吧?
    不知道apache设置是否有问题。
      

  3.   

    我用PHP写了个webservice服务器端,可以调用,但是我用PHP去调用其它的webservice,一到执行$client->call方法就跟死循环一样,哎,不知是哪的问题。
      

  4.   

    这是我这边的一份代码,你可以学习下,
    function getSSOLoginID($sessionID) { if ($sessionID == "") {
    return "";
    }
    // SOAP接続
    $soapclient =& new soapclient('http'//localhost/AuthCheckService?wsdl',true);
    $soapclient->debug_flag=true; $soapclient->timeout = 500;
    $soapclient->response_timeout = 500; if($err = $soapclient->getError()){
    execSSOLogWrite($err);
    return "";
    } $proxy = $soapclient->getProxy();
    if($err = $soapclient->getError()){
    execSSOLogWrite($err);
    return "";
    }

    $params = array('MISUMISESSION' => $sessionID);
    $result = $proxy->doAuthCheck($params);
    $status = $result['STATUS'];
    $userid = $result['USERID'];

    if ($status == "1") {
    return $userid;
    } else {
    return "";
    }
    }