PHP SOAP webservice 连接超时的问题

WBOY
Release: 2016-06-23 13:32:07
Original
1697 people have browsed it

最近需要打一个php soap webservice 写了个测试的demo 代码非常简单
网上也看了不少教程 碰到一个棘手的问题

服务端 service.php

<?phpclass service{    public function HelloWorld()    {        return "Hello";    }    public  function Add($a,$b)    {        return $a+$b;    }}$server=new SoapServer('TestSoap.wsdl',array('soap_version' => SOAP_1_2));$server->setClass("service");$server->handle();?>
Copy after login


客户端 client.php
<?php//$soap = new SoapClient("http://localhost/web/TestSoap.wsdl", array('soap_version' => SOAP_1_2));$soap = new SoapClient("TestSoap.wsdl", array('soap_version' => SOAP_1_2));echo $soap->Add(1,6);echo $soap->HelloWorld()."<br />";?>
Copy after login


wsdl已经生成 没有问题

现在的问题是 客户端代码中 

如果想现在这样直接写TestSoap.wsdl(client和wsdl在同个文件夹下)就能正常返回结果:7HELLO

如果把wsdl的地址写成http的 像注释掉的那句一样 浏览器就提示超时
Fatal error: Maximum execution time of 30 seconds exceeded in D:\PHPWeb\web\client.php on line 0

有没有大神能够解释一下为什么


回复讨论(解决方案)

$soap = new SoapClient("http://localhost/web/service.php?wsdl", array('soap_version' => SOAP_1_2));
第二个参数可以不要

$soap = new SoapClient("http://localhost/web/service.php?wsdl", array('soap_version' => SOAP_1_2));
第二个参数可以不要

第二个参数删了结果还是一样

看看你的wsdl文件的soap:address返回的地址端口是否正确的
WSDL-Endpoint:





我也遇到这个问题,求解答。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template