简体   繁体   English

带有PHP的Web服务(wsdl)

[英]Web Services (wsdl) with Php

I have been working on php for a long time but this time i have a got an API where i have to connect with a WSDL file using php , i have tried a lot different ways but i am not getting any response. 我已经在php上工作了很长时间,但是这次我有一个API,我必须使用php与WSDL文件连接,我尝试了很多不同的方法,但是没有得到任何回应。

Here's my wsdl file 这是我的wsdl文件

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
name="WMSMSWS"
targetNamespace="http://www.gspl.com/wms/wtystatus"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.gspl.com/wms/wtystatus"
xmlns:xsd1="http://www.gspl.com/wms/wtystatus/xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema
   targetNamespace="http://www.gspl.com/wms/wtystatus/xsd"
   xmlns="http://www.w3.org/2001/XMLSchema"
   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
   elementFormDefault="qualified">

  <xsd:element name="wtyStatusData">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element minOccurs="1" maxOccurs="1"
                     name="machineSerialNo" type="xsd:string" />
        <xsd:element minOccurs="1" maxOccurs="1"
                     name="serviceUserId" type="xsd:string" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="wtyStatusDataResponse">
    <xsd:complexType>
      <xsd:sequence>
      <xsd:element minOccurs="1" maxOccurs="1"
                     name="status" type="xsd:string" />
      <xsd:element minOccurs="0" maxOccurs="1"
                     name="error" type="xsd:string" />
      <xsd:element minOccurs="0" maxOccurs="1"
                     name="wtyStatus" type="xsd:string" />
      <xsd:element minOccurs="0" maxOccurs="1"
                     name="modelNo" type="xsd:string" />
      <xsd:element minOccurs="0" maxOccurs="1"
                     name="wtyEndDate" type="xsd:string" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  </xsd:schema>
</wsdl:types>
<wsdl:message name="wtyStatusData">
<wsdl:part name="parameters" element="xsd1:wtyStatusData" />
</wsdl:message>
<wsdl:message name="wtyStatusDataResponse">
<wsdl:part name="parameters" element="xsd1:wtyStatusDataResponse" />
</wsdl:message>
<wsdl:portType name="WMSMSWSPortType">
 <wsdl:operation name="wtyStatusData">
  <wsdl:input message="tns:wtyStatusData" />
  <wsdl:output message="tns:wtyStatusDataResponse" />
  </wsdl:operation>
  </wsdl:portType>
   <wsdl:binding name="WMSMSWSPortBinding"
            type="tns:WMSMSWSPortType">
   <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
              style="document" />

   <wsdl:operation name="wtyStatusData">
  <soap:operation soapAction="http://www.gspl.com/wms/wtystatus/wtyStatusData"
                  style="document" />
  <wsdl:input>
    <soap:body use="literal" />
  </wsdl:input>
  <wsdl:output>
    <soap:body use="literal" />
  </wsdl:output>
</wsdl:operation>
 </wsdl:binding>
 <wsdl:service name="WtyStatus">
  <wsdl:port name="WMSMSWSPort" binding="tns:WMSMSWSPortBinding">
  <soap:address location="http://ecsm.net:8080/wms/services/WtyStatus" />
 </wsdl:port>
   </wsdl:service>
  </wsdl:definitions>

and the php i am writing for it 和PHP,我为此写

  <?php
require_once('nusoap.php'); 
$wsdl="http://ecsm.net:8080/wms/services/WtyStatus";
$client=new soapclient($wsdl, 'wsdl');

$machineSerialNo = 'KZ10187M';
$serviceUserId = 'LBZ01554';

$param=array(
    'machineSerialNo' => $machineSerialNo, 
    'serviceUserId' => $serviceUserId
    );

$result = $client->call('WMSMSWS', $param);

echo $client->getError();

print_r($result);

I am using Soap to connect to it , Machine Serial No and Service User Id are unique given to me from a company. 我正在使用Soap进行连接,机器序列号和服务用户ID是公司给我的唯一信息。

Thanks 谢谢

Take a look at using __doRequest() or __soapCall() instead as __call() is deprecated in current versions of PHP. 看一下使用__doRequest()__soapCall()来代替,因为在当前版本的PHP中不推荐使用__call() If you're still having problems you can start debugging by using is_soap_fault() 如果仍有问题,可以使用is_soap_fault()开始调试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM