几天前,我开始开发自己的 Web 服务。我决定使用 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。对不起我的英语,这不是我的母语
终于,我成功了!该问题是由HTTP版本引起的。解决办法如下:
...
<inSequence>
<log level="full"/>
<property name="FORCE_HTTP_1.0" value="true" scope="axis2" type="BOOLEAN"/>
</inSequence>
...
我希望有一天它会对某人有所帮助。