wsdl文件要求,如下:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:sch="http://trace.bnet.cn/locRes"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://trace.bnet.cn/locRes"
targetNamespace="http://trace.bnet.cn/locRes">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://trace.bnet.cn/locRes">
<element name="locationResponseRequest">
<complexType>
<sequence>
<element name="locationRequestID" type="string" />
<element name="locResults" type="string" />
</sequence>
</complexType>
</element>
<element name="locationResponseResponse" type="string" />
</schema>
</wsdl:types>
<wsdl:message name="locationResponseResponse">
<wsdl:part element="tns:locationResponseResponse"
name="locationResponseResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="locationResponseRequest">
<wsdl:part element="tns:locationResponseRequest"
name="locationResponseRequest">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="LocRes">
<wsdl:operation name="locationResponse">
<wsdl:input message="tns:locationResponseRequest"
name="locationResponseRequest">
</wsdl:input>
<wsdl:output message="tns:locationResponseResponse"
name="locationResponseResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="LocResSoap11" type="tns:LocRes">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="locationResponse">
<soap:operation soapAction="" />
<wsdl:input name="locationResponseRequest">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="locationResponseResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="LocResService">
<wsdl:port binding="tns:LocResSoap11" name="LocResSoap11">
<soap:address
location=" " />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>接口名,叫locationResponse 这个,接收两个参数,发求发布的wsdl文件如上一样,谢谢了webservicephpsoap
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:sch="http://trace.bnet.cn/locRes"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://trace.bnet.cn/locRes"
targetNamespace="http://trace.bnet.cn/locRes">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://trace.bnet.cn/locRes">
<element name="locationResponseRequest">
<complexType>
<sequence>
<element name="locationRequestID" type="string" />
<element name="locResults" type="string" />
</sequence>
</complexType>
</element>
<element name="locationResponseResponse" type="string" />
</schema>
</wsdl:types>
<wsdl:message name="locationResponseResponse">
<wsdl:part element="tns:locationResponseResponse"
name="locationResponseResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="locationResponseRequest">
<wsdl:part element="tns:locationResponseRequest"
name="locationResponseRequest">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="LocRes">
<wsdl:operation name="locationResponse">
<wsdl:input message="tns:locationResponseRequest"
name="locationResponseRequest">
</wsdl:input>
<wsdl:output message="tns:locationResponseResponse"
name="locationResponseResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="LocResSoap11" type="tns:LocRes">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="locationResponse">
<soap:operation soapAction="" />
<wsdl:input name="locationResponseRequest">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="locationResponseResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="LocResService">
<wsdl:port binding="tns:LocResSoap11" name="LocResSoap11">
<soap:address
location=" " />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>接口名,叫locationResponse 这个,接收两个参数,发求发布的wsdl文件如上一样,谢谢了webservicephpsoap
解决方案 »
- PHP面向对象学习——类的实践
- 菜鸟提问:关于网络考试系统操作题批阅的代码
- 本地能导出excel2007,服务器却不能,为什么?
- LINUX 下 为什么PHP从MYSQL里读取出来的数据还是乱码
- 请教php页面提交问题
- 求助:如何使用PHP编写一个网页被关闭后自动执行的函数
- 写PHP1年多,接下去我该怎么办?
- xmlhttp对象POST发送的中文在php下用$_POST[]接收成为乱码?????
- 有没有像CSDN\QQ\UC\网易\搜狐那种形式的PHP论坛下载?谢谢.急急....
- mcrypt 编码函式库????
- 大侠求助!Thinkphp 如何输出指定值数据
- 有没有匹配url但除了图片之外的正则表达式?
均放在网站的 soap 目录下
修改 wsdl 文件最后一节为
<wsdl:service name="LocResService">
<wsdl:port binding="tns:LocResSoap11" name="LocResSoap11">
<soap:address
location="http://localhost/soap/LocRes.php" />
</wsdl:port>
</wsdl:service>
实际使用时需安真实域名、路径填写
2、服务端程序 LocRes.phpclass Service{
public function locationResponse($in) {
//这里是实际处理的代码
return "param:$in->locationRequestID $in->locResults";
}
}$server = new SoapServer('LocRes.wsdl');
$server -> setClass("service");
$server -> handle();3、测试用客户端代码
$url = 'http://localhost/soap/LocRes.php?WSDL';
$soapClient = new soapclient($url);$a = array(
'locationRequestID' => 2,
'locResults' => 'abcd',
);echo $soapClient->locationResponse($a);
得到
param:2 abcd
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in E:\phproot\Card01\app\service\index.php:11 Stack trace: #0 E:\phproot\Card01\app\service\index.php(11): SoapClient->__call('locationRespons...', Array) #1 E:\phproot\Card01\app\service\index.php(11): SoapClient->locationResponse(Array) #2 {main} thrown in
麻烦,你看一下呢?
想问一下,java 调我这个webservice ,怎么说not found ,404错误呢?有解决方法吗
比如说访问 http://www.webxml.com.cn/WebServices/ChinaStockWebService.asmx?wsdl2、确认你的服务端程序能通过php的客户端测试
$soapClient = new soapclient('http://sanchen.ismartinfo.cn/findeasy/soap/soap.wsdl');
$list = $soapClient->__getFunctions();
print_r($list);$a = array(
'locationRequestID' => 2,
'locResults' => 'abcd',
);
echo $soapClient->locationResponse(array('locationRequestID'=>565656,'locResults'=>'121212'));
$server = new SoapServer('LocRes.wsdl', array('soap_version' => SOAP_1_2));
ini_set("soap.wsdl_cache_enabled", "0");
class service{
public function locationResponse($in) {
//这里是实际处理的代码
file_put_contents("bb.txt","param:$in->locationRequestID $in->locResults");
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><result><code>0</code><desc></desc></result>";
}
}
$server=new SoapServer('soap.wsdl',array('soap_version' => SOAP_1_2)); //创建SoapServer对象
$server -> setClass("service");
$server -> handle();
他们的 java 代码是工具生成的吗?soap 技术源于微软,对书写格式要求还是比较严格的。稍有不慎就要出错
所以一般都用工具生成 wsdl,然后用工具从 wsdl 生成服务端代码和客户端代码php 由于没有提供生成工具,所以产生的服务可能并不标准