2017-07-24 138 views
0

我正在尝试使用webservice(Swiss Post Track托运)更新Prestashop订单状态以在交付时交付。使用xml文件而不是wsdl的PHP SOAP请求

,我已经给出了请求的文件看起来像这样(.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文件而不是wsd l,但无论如何,我可以使用这个XML文件与SoapClient()或有没有办法将我的XML文件转换为wsdl用于SoapClient()?

谢谢,任何帮助将被大大appreaciated!

回答

0

林不知道你到底需要什么。 WSDL文件也是XML文件,但相反不适用。 XML是一种通用的数据格式,可以包含任何类型的信息。 WSDL是用于描述Web服务的特定XML。

请检查wiki for further clarification。 不确定你有什么样的XML。它可能是测试数据,或带有不正确文件后缀的WSDL。您需要检查这些文件的内容

样品WSDL文件可以在这里找到: https://www.w3.org/2001/04/wsws-proceedings/uche/wsdl.html