【发布时间】:2011-08-22 19:06:12
【问题描述】:
我正在尝试基于我为我们的目的而修改的 WSDL 创建一个 PHP 肥皂服务器。我认为,问题来自 WSDL 文件的形式。当我在这里测试它时:http://www.validwsdl.com/,响应消失并告诉我该功能不存在。
这个想法是预期的输入是 4 项,这 4 项将被放入函数中,使用,另外 4 项将被返回。我在这里删除了样本中除了返回之外的所有内容,但这个想法应该仍然有效。
这是我的 PHP 代码:
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("InventoryInquiry.wsdl");
$server->addFunction("GetInventoryStatus");
$server->handle();
function GetInventoryStatus($request) {
$dealerBranch = 1;//default branch to 1
$inStock = 0;//default in stock to 0
$cantTrack = 0; //used to check if branch is tracked
$estDeliveryTime = "";
$estDeliveryDate = "";
$deliveryLocation = "";
return array(
'InStock' => $inStock,
'EstDeliveryDate' =>$estDeliveryDate,
'EstDeliveryTime'=> $estDeliveryTime,
'DeliveryLocation' => $dealerBranch
);
}
这是我的 wsdl 文件:
<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://www.elennox.net/server1.php/" 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://www.elennox.net/server1.php" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.elennox.net/server1.php">
<s:element name="GetInventoryStatus">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="DealerCode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SupplierCode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PartNumber" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="Quantity" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetInventoryStatusResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="InStock" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="EstDeliveryDate" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EstDeliveryTime" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="DeliveryLocation" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="InventoryRequestRequest">
<wsdl:part name="parameters" element="tns:GetInventoryStatus" />
</wsdl:message>
<wsdl:message name="InventoryRequestResponse">
<wsdl:part name="parameters" element="tns:GetInventoryStatusResponse" />
</wsdl:message>
<wsdl:portType name="InventoryStatusPortType">
<wsdl:operation name="InventoryRequest">
<wsdl:input message="tns:InventoryRequestRequest" />
<wsdl:output message="tns:InventoryRequestResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="InventoryStatusBinding" type="tns:InventoryStatusPortType">
<soap:binding style='rpc' transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="InventoryRequest">
<soap:operation soapAction="http://www.elennox.net/server1.php#InventoryStatus" style="document" />
<wsdl:input>
<soap:body use="literal" namespace="urn:InventoryStatus"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="urn:InventoryStatus"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="InventoryStatus">
<wsdl:port name="InventoryStatusPort" binding="tns:InventoryStatusBinding">
<soap:address location="http://www.elennox.net/server1.php" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
总的来说,我对这个 Web 服务还很陌生,而且我玩得很开心。任何提示或帮助将不胜感激。谢谢!
【问题讨论】: