使用Soap Service时,结果为空,为什么在getLastResponse中填充XML。这是WSDL:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://schema.XXX.com/WebAPI/1.0/Search" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:s1="http://schema.XXX.com/WebAPI/1.0/Common" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://schema.XXX.com/WebAPI/1.0/Search" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">A web service used to perform searches on an instance's data.</wsdl:documentation>
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://schema.XXX.com/WebAPI/1.0/Search">
<s:import namespace="http://schema.XXX.com/WebAPI/1.0/Common" schemaLocation="http://localhost:8090/Services/Common.xsd" />
<s:element name="SearchRequest" type="tns:SearchRequest" />
<s:complexType name="SearchRequest">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="Contexts" type="s1:FilterContext" />
</s:sequence>
</s:complexType>
<s:element name="SearchResponse" type="tns:SearchResponse" />
<s:complexType name="SearchResponse">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="Items" type="tns:SearchResultItem" />
<s:element minOccurs="0" maxOccurs="1" name="Status" type="s1:SoapResponseStatus" />
</s:sequence>
</s:complexType>
<s:complexType name="SearchResultItem">
<s:complexContent mixed="false">
<s:extension base="s1:ItemKey">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="DisplayName" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="ResultType" type="s1:FilterContextType" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="SearchSoapIn">
<wsdl:part name="Request" element="tns:SearchRequest" />
</wsdl:message>
<wsdl:message name="SearchSoapOut">
<wsdl:part name="SearchResult" element="tns:SearchResponse" />
</wsdl:message>
<wsdl:portType name="SearchWebServiceSoap">
<wsdl:operation name="Search">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Performs a search based on requested contexts and filters.</wsdl:documentation>
<wsdl:input message="tns:SearchSoapIn" />
<wsdl:output message="tns:SearchSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SearchWebServiceSoap" type="tns:SearchWebServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Search">
<soap:operation soapAction="http://schema.XXX.com/WebAPI/1.0/Search/Search" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="SearchWebServiceSoap12" type="tns:SearchWebServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Search">
<soap12:operation soapAction="http://schema.XXX.com/WebAPI/1.0/Search/Search" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SearchWebService">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">A web service used to perform searches on an instance's data.</wsdl:documentation>
<wsdl:port name="SearchWebServiceSoap" binding="tns:SearchWebServiceSoap">
<soap:address location="http://localhost:50295/Services/SearchWebService.asmx" />
</wsdl:port>
<wsdl:port name="SearchWebServiceSoap12" binding="tns:SearchWebServiceSoap12">
<soap12:address location="http://localhost:50295/Services/SearchWebService.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
<?xml version="1.0" encoding="utf-8"?>
<s:schema xmlns="http://schema.XXX.com/WebAPI/1.0/Common"
xmlns:s="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://schema.XXX.com/WebAPI/1.0/Common">
<s:complexType name="ItemKey">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SiteId" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="ItemId" type="s:int" />
</s:sequence>
</s:complexType>
<s:complexType name="SoapResponseStatus">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="Succeeded" type="s:boolean" />
<s:element minOccurs="1" maxOccurs="1" name="ErrorCode" type="s:int" />
</s:sequence>
</s:complexType>
<s:complexType name="ItemKeyRequest">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Key" type="ItemKey" />
</s:sequence>
</s:complexType>
<s:complexType name="FilterContext">
<s:complexContent mixed="false">
<s:extension base="IFilter">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="ContextType" type="FilterContextType" />
<s:element minOccurs="0" maxOccurs="1" name="FilterGroup" type="FilterGroup" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
<s:complexType name="IFilter" abstract="true" />
<s:complexType name="FilterValue">
<s:complexContent mixed="false">
<s:extension base="IFilter">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Key" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="OperatorType" type="OperatorType" />
<s:element minOccurs="0" maxOccurs="1" name="Value" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SchemaTypeName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SchemaTypeNamespace" type="s:string" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
<s:simpleType name="OperatorType">
<s:restriction base="s:string">
<s:enumeration value="NotSet" />
<s:enumeration value="Equal" />
<s:enumeration value="GreaterThan" />
<s:enumeration value="LessThan" />
<s:enumeration value="GreaterThanEqual" />
<s:enumeration value="LessThanEqual" />
<s:enumeration value="Contains" />
<s:enumeration value="StartsWith" />
<s:enumeration value="EndsWith" />
</s:restriction>
</s:simpleType>
<s:complexType name="FilterContainer">
<s:complexContent mixed="false">
<s:extension base="IFilter">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="FilterValue" type="FilterValue" />
<s:element minOccurs="0" maxOccurs="1" name="FilterGroup" type="FilterGroup" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
<s:complexType name="FilterGroup">
<s:complexContent mixed="false">
<s:extension base="IFilter">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="GroupType" type="FilterGroupType" />
<s:element minOccurs="0" maxOccurs="unbounded" name="Filters" type="FilterContainer" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
<s:simpleType name="FilterGroupType">
<s:restriction base="s:string">
<s:enumeration value="And" />
<s:enumeration value="Or" />
</s:restriction>
</s:simpleType>
<s:simpleType name="FilterContextType">
<s:restriction base="s:string">
<s:enumeration value="Hierarchy" />
<s:enumeration value="ReportDefinition" />
<s:enumeration value="GeneratedReport" />
<s:enumeration value="Role" />
<s:enumeration value="User" />
</s:restriction>
</s:simpleType>
</s:schema>
PHP代码:
$client = new SoapClient("SearchWebService.wsdl", array('location' => "$usingSSL://$hostname/axis2/services/SearchWebService", 'trace' => 1, 'exceptions' => 1));
$data = json_decode(stripslashes($_POST["data"]));
$result = $client->Search($data);
__使用getLastResponse:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<n:SearchResponse xmlns:n="http://schema.XXX.com/WebAPI/1.0/Search" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n0="http://schema.XXX.com/WebAPI/1.0/Common">
<n:Responses>
<n:Items>
<n0:SiteId/>
<n0:ItemId>22</n0:ItemId>
<n:DisplayName>Floor 1</n:DisplayName>
<n:ResultType>Hierarchy</n:ResultType>
</n:Items>
<n:Items>
<n0:SiteId/>
<n0:ItemId>196</n0:ItemId>
<n:DisplayName>Floor 1</n:DisplayName>
<n:ResultType>Hierarchy</n:ResultType>
</n:Items>
<n:Status>
<n0:Succeeded>true</n0:Succeeded>
<n0:ErrorCode>0</n0:ErrorCode>
</n:Status>
</n:Responses>
</n:SearchResponse>
</soapenv:Body>
</soapenv:Envelope>
$结果总是空的。没有错误。我尝试了类图和相同的结果。
有什么想法吗?
答案 0 :(得分:0)
尝试对结果进行var_dump()...你看到了什么?
此外,您也可以尝试这一点,将其包裹在搜索电话周围:
try {
$result = $client->Search($data);
} catch (SoapFault $exception) {
//We errored
echo $exception;
}