几天前,我开始研究自己的 WebServices。我决定使用 WSO2 WSF/PHP 框架,并根据http://wso2.org/project/wsf/php/2.0.0/docs/manual.html创建了我的第一个 helloService。这是代码:
function greet($message) {
$responsePayloadString = <<<XML
<greetResponse>Hello Client!</greetResponse>
XML;
$returnMessage = new WSMessage($responsePayloadString);
return $returnMessage;
}
$service = new WSService(array("operations" => array("greet")));
$service->reply();
我已经将它部署在我的服务器上,并尝试使用简单的 helloClient(在 wso2 wsf/php 手册中描述)和 SoapUI 来调用它——一切正常。现在我会尝试在我的 WSO2 ESB 上部署它,所以我定义了这样的新代理服务:
<proxy name="helloService" transports="https http" startOnLoad="true" trace="disable">
<target endpoint="helloService">
<inSequence>
<log level="full"/>
</inSequence>
<outSequence>
<filter xpath="get-property('FAULT')">
<then>
<log level="full" category="WARN" separator=",">
<property name="message" value="SOAP Fault detected"/>
</log>
</then>
<else/>
</filter>
<send/>
</outSequence>
<faultSequence>
<log level="full">
<property name="MESSAGE" value="Executing default 'fault' sequence"/>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
</log>
<drop/>
</faultSequence>
</target>
<publishWSDL uri="http://myAPIAddress/helloService.php?wsdl"/>
</proxy>
<endpoint name="helloService">
<address uri="http://myAPIAddress/helloService.php" format="soap11"/>
</endpoint>
新服务在 ESB 管理控制台的“已部署服务”列表中可见,我可以从 myESBaddress:8280/services/helloService?wsdl 获取 WSDL,并且在 myESBaddress:8280/services 列表中一切正常。但是,当我想使用“试用此服务”选项时,会出现超时错误。我尝试使用 SoapUI 调用我的 WS - 对端点 myESBaddress:8280/services/helloService 的请求看起来像(当我将它发送到 myAPIAddress/helloService.php 时,相同的请求工作正常)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.wso2.org/php/xsd">
<soapenv:Header/>
<soapenv:Body>
<greet>asdfasdfas</greet>
</soapenv:Body>
</soapenv:Envelope>
不幸的是,作为回应,我有一个错误:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>411</faultcode>
<faultstring>Unexpected response received. HTTP response code : 411 HTTP status : Length Required exception : First Element must contain the local name, Envelope , but found html</faultstring>
<detail>Unexpected response received. HTTP response code : 411 HTTP status : Length Required exception : First Element must contain the local name, Envelope , but found html</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
我做错了什么?我有感觉,这是完全愚蠢和明显的事情,所以如果这是新手问题,请原谅我,但经过几天的挖掘解决方案后,我真的很绝望。
PS。对不起我的英语,这不是我的母语