0
好日子亲爱的朋友。我打算调用PHP网络服务,使用net winform应用程序创建SoapServer。 PHP方法recieving XML字符串作为参数并返回JSON编码数组:从网络应用调用php web服务
function getPolicy($contentsXml) {
if ($everyting->isOK) {
$resultArr = createResultArray();
}else{
// Process errors
}
$result = json_encode($resultArr);
return $result;
}
这是WSDL包含在PHP web服务我使用Web引用添加到视觉工作室:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="XmlImportClaimWSDL"
targetNamespace="http://172.16.6.130/online/my.wsdl"
xmlns:tns="http://172.16.6.130/online/my.wsdl"
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://tempuri.org/" >
<element name="getPolicy">
<complexType>
<sequence>
<element minOccurs="0" maxOccurs="1" name="contentsXml" type="xsd:string" />
</sequence>
</complexType>
</element>
<element name="getPolicyResponse">
<complexType>
<sequence>
<element minOccurs="0" maxOccurs="1" name="contentsXml" type="xsd:json" />
</sequence>
</complexType>
</element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getPolicyRequest">
<wsdl:part name="requestParam" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="getPolicyResponse">
<wsdl:part name="responseParam" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="ServerClaimSoapType">
<wsdl:operation name="getPolicy">
<wsdl:input message="tns:getPolicyRequest" />
<wsdl:output message="tns:getPolicyResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ServerClaimSoapBinding" type="tns:ServerClaimSoapType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<wsdl:operation name="getPolicy">
<soap:operation soapAction="http://php-server-address/"/>
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ServerClaim">
<wsdl:port name="ServerClaimSoap" binding="tns:ServerClaimSoapBinding">
<soap:address location="http://php-server-address/phpSoapService.php" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
正如我从提琴手可以看到的,PHP接收参数并返回正确的json对象,但在网络代码中结果始终为空。净代码:
PhpSoapObject client = new PhpSoapObject();
var result = client.getPolicy(PredifenedXmlString);
所以结果变量总是空;我的猜测是wsdl绑定。我对这种情况进行了很多搜索。我已经意识到,使用PHP网络服务与网络框架没有nusoap记录非常差。感谢大家阅读这么长的问题。