请教一个php调用webservice的问题

aizlcm 2014-08-07 11:04:12
地址 :http://172.16.33.26/purchase/Service1.asmx?wsdl
$client = new Soap_Client("http://172.16.33.26/purchase/Service1.asmx?wsdl");
我这样调用错误。
由于接口只有内网才能打开,我把代码贴出来

<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
- <s:element name="Invoice">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="kprqq" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="kprqz" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SAPNUMBER" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="InvoiceResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="InvoiceResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
- <wsdl:message name="InvoiceSoapIn">
<wsdl:part name="parameters" element="tns:Invoice" />
</wsdl:message>
- <wsdl:message name="InvoiceSoapOut">
<wsdl:part name="parameters" element="tns:InvoiceResponse" />
</wsdl:message>
- <wsdl:portType name="Service1Soap">
- <wsdl:operation name="Invoice">
<wsdl:input message="tns:InvoiceSoapIn" />
<wsdl:output message="tns:InvoiceSoapOut" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="Service1Soap" type="tns:Service1Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="Invoice">
<soap:operation soapAction="http://tempuri.org/Invoice" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="Service1Soap12" type="tns:Service1Soap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="Invoice">
<soap12:operation soapAction="http://tempuri.org/Invoice" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="Service1">
- <wsdl:port name="Service1Soap" binding="tns:Service1Soap">
<soap:address location="http://172.16.33.26/purchase/Service1.asmx" />
</wsdl:port>
- <wsdl:port name="Service1Soap12" binding="tns:Service1Soap12">
<soap12:address location="http://172.16.33.26/purchase/Service1.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
...全文
147 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
猪崽儿0o0 2014-08-07
  • 打赏
  • 举报
回复
PHP调用webservice就是按照接口类型和需要传递的参数组装好后使用soap协议发送过去后会返回对应的结果给你,然后接收后做处理即可。
xuzuning 2014-08-07
  • 打赏
  • 举报
回复
可能是你的 WSDL 有 BOM 头或开始处有空行引起的 我解析你的 WSDL 时就发现开始处有空行,还以为是复制的问题呢
xuzuning 2014-08-07
  • 打赏
  • 举报
回复
方法
Array
(
    [0] => InvoiceResponse Invoice(Invoice $parameters)
    [1] => InvoiceResponse Invoice(Invoice $parameters)
)
数据结构
Array
(
    [0] => struct Invoice {
 string kprqq;
 string kprqz;
 string SAPNUMBER;
}
    [1] => struct InvoiceResponse {
 string InvoiceResult;
}
)

有什么问题请直说
aizlcm 2014-08-07
  • 打赏
  • 举报
回复
上面发错了
$client = new SoapClient($this->serviceUrl);
错误:SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://172.16.33.26/purchase/Service1.asmx?wsdl' : failed to load external entity "http://172.16.33.26/purchase/Service1.asmx?wsdl"
xuzuning 2014-08-07
  • 打赏
  • 举报
回复
如果使用 soap 扩展 $client = new SoapClient("http://172.16.33.26/purchase/Service1.asmx?wsdl"); 如果使用 nusoap 类库 $client = new Soap_Client("http://172.16.33.26/purchase/Service1.asmx?wsdl"); 关键是你要把 WSDL 文件搞正确了
aizlcm 2014-08-07
  • 打赏
  • 举报
回复
求调用的方法
aizlcm 2014-08-07
  • 打赏
  • 举报
回复
$client = new SoapClient($Url); 不能使用这种方法调用
aizlcm 2014-08-07
  • 打赏
  • 举报
回复
我是个新手,请问现在我应该如何调用?

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧