[英]SOAP request with PHP using an xml file instead of wsdl
我正在尝试使用网络服务(瑞士邮政跟踪寄售)将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。
请检查Wiki以获得进一步的说明 。 不知道您拥有哪种XML。 它可能是测试数据,或者文件后缀不正确的WSDL。 您需要检查文件的内容
可以在以下位置找到示例WSDL文件: https : //www.w3.org/2001/04/wsws-proceedings/uche/wsdl.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.