我正在尝试使用网络服务(瑞士邮政跟踪托运(将Prestashop订单状态更新为货到付款。
我收到的请求文件如下所示(.xml(
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp200409="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsp200607="http://www.w3.org/2006/07/ws-policy" xmlns:ns0="http://www.post.ch/npp/trackandtracews/v02/masterdata/definitions" targetNamespace="http://www.post.ch/npp/trackandtracews/v02/masterdata/definitions">
<wsdl:types xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema>
<xsd:import schemaLocation="MasterData.ws.xsd1.xsd" namespace="http://www.post.ch/npp/masterdata/v02"/></xsd:schema></wsdl:types>
<wsdl:message name="DetailRequest">
<wsdl:part name="DetailRequest" element="xsns:DetailReq" xmlns:xsns="http://www.post.ch/npp/masterdata/v02"/></wsdl:message>
<wsdl:message name="DetailResponse">
<wsdl:part name="DetailResponse" element="xsns:DetailRes" xmlns:xsns="http://www.post.ch/npp/masterdata/v02"/></wsdl:message>
<wsdl:message name="EventsRequest">
<wsdl:part name="EventsRequest" element="xsns:EventsReq" xmlns:xsns="http://www.post.ch/npp/masterdata/v02"/></wsdl:message>
<wsdl:message name="EventsResponse">
<wsdl:part name="EventsResponse" element="xsns:EventsRes" xmlns:xsns="http://www.post.ch/npp/masterdata/v02"/></wsdl:message>
<wsdl:message name="StatusesRequest">
<wsdl:part name="StatusesRequest" element="xsns:StatusReq" xmlns:xsns="http://www.post.ch/npp/masterdata/v02"/></wsdl:message>
<wsdl:message name="StatusesResponse">
<wsdl:part name="StatusesResponse" element="xsns:StatusRes" xmlns:xsns="http://www.post.ch/npp/masterdata/v02"/></wsdl:message>
<wsdl:portType name="MasterDataResource">
<wsdl:operation name="GetAllDetails">
<wsdl:input name="DetailRequest" message="ns0:DetailRequest"/>
<wsdl:output name="DetailResponse" message="ns0:DetailResponse"/></wsdl:operation>
<wsdl:operation name="GetAllEvents">
<wsdl:input name="EventsRequest" message="ns0:EventsRequest"/>
<wsdl:output name="EventsResponse" message="ns0:EventsResponse"/></wsdl:operation>
<wsdl:operation name="GetAllStatuses">
<wsdl:input name="StatusesRequest" message="ns0:StatusesRequest"/>
<wsdl:output name="StatusesResponse" message="ns0:StatusesResponse"/></wsdl:operation></wsdl:portType>
<wsdl:binding name="MasterDataBinding" type="ns0:MasterDataResource">
<soap11:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="GetAllDetails">
<soap11:operation soapAction="http://www.post.ch/npp/masterdataws/v02/GetAllDetails" style="document"/>
<wsdl:input name="DetailRequest">
<soap11:body use="literal"/></wsdl:input>
<wsdl:output name="DetailResponse">
<soap11:body use="literal"/></wsdl:output></wsdl:operation>
<wsdl:operation name="GetAllEvents">
<soap11:operation soapAction="http://www.post.ch/npp/masterdataws/v02/GetAllEvents" style="document"/>
<wsdl:input name="EventsRequest">
<soap11:body use="literal"/></wsdl:input>
<wsdl:output name="EventsResponse">
<soap11:body use="literal"/></wsdl:output></wsdl:operation>
<wsdl:operation name="GetAllStatuses">
<soap11:operation soapAction="http://www.post.ch/npp/masterdataws/v02/GetAllStatuses" style="document"/>
<wsdl:input name="StatusesRequest">
<soap11:body use="literal"/></wsdl:input>
<wsdl:output name="StatusesResponse">
<soap11:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding>
<wsdl:service name="MasterDataService">
<wsdl:port name="MasterDataPort" binding="ns0:MasterDataBinding">
<soap11:address location="https://webservices.post.ch:443/IN_MYPBxTT/services/MasterData.ws"/></wsdl:port>
<wsdl:port name="MasterDataPort.0" binding="ns0:MasterDataBinding">
<soap11:address location="https://webservices.post.ch:443/IN_MYPBxTT/services/MasterData.ws"/></wsdl:port></wsdl:service></wsdl:definitions>
我正在尝试使用此PHP访问此文件
// SOAP Configuration
$SOAP_wsdl_file_path = 'MasterData.xml';
$SOAP_config = array(
// Webservice Endpoint URL
'location' => 'https://webservices.post.ch/IN_MYPBxTT/services/TrackAndTraceDFU.ws',
// Webservice Login
'login' => $login,
'password' => $pass,
);
// SOAP Connection
try {
$SOAP_Client = new SoapClient($SOAP_wsdl_file_path, $SOAP_config);
} catch (SoapFault $fault) {
die('<pre>Error in SOAP Initialization: '.$fault->__toString().'</pre>');
}
?>
这将生成此错误:
SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema
from '/pathto/MasterData.ws.xsd1.xsd' in /pathto/request.php:22
Stack trace:
#0 /pathto/request.php(22): SoapClient->SoapClient('MasterData.xml', Array)
#1 {main}
我知道这个问题来自我使用的是 xml 文件而不是 wsdl 的事实,但是无论如何我可以将此 xml 文件与 SoapClient((一起使用,或者有没有办法将我的 xml 文件转换为 wsdl 以用于 SoapClient(( ?
谢谢,任何帮助将不胜感激!
我不确定你到底需要什么。WSDL 文件也是 XML 文件,但反之则不适用。 XML 是一种通用数据格式,可以包含任何类型的信息。 WSDL 是用于描述 Web 服务的特定 XML。
请查看维基以获取进一步的说明。 不确定您拥有哪种 XML。它可能是测试数据,也可能是文件后缀不正确的 WSDL。您需要检查文件的内容
可以在此处找到示例 WSDL 文件: https://www.w3.org/2001/04/wsws-proceedings/uche/wsdl.html