结合使用PHP SoapClient和Java JAX-WS RI(Webservice) [英] Using PHP SoapClient with Java JAX-WS RI (Webservice)
问题描述
对于一个新项目,我们想使用JAX-WS RI在Java中构建一个Web服务,对于Web服务客户端,我们想使用PHP.
For a new project, we want to build a web service in Java using JAX-WS RI, and for the web service client, we want to use PHP.
在有关JAX-WS RI的小型教程中,我找到了此示例Web服务:
In a small tutorial about JAX-WS RI I found this example web service:
package webservice;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
@WebService
@SOAPBinding(style = Style.RPC)
public class Calculator {
public long addValues(int val1, int val2) {
return val1 + val2;
}
}
以及对于Web服务器:
and for the web server:
package webservice;
import javax.xml.ws.Endpoint;
import webservice.Calculator;
public class CalculatorServer {
public static void main(String args[]) {
Calculator server = new Calculator();
Endpoint endpoint = Endpoint.publish("http://localhost:8080/calculator", server);
}
}
启动服务器并使用URL" http://localhost:8080/calculator?wsdl "的效果很好.但是从PHP调用Web服务失败.
Starting the Server and browsing the WDSL with the URL "http://localhost:8080/calculator?wsdl" works perfectly. But calling the web service from PHP fails.
我非常简单的PHP调用看起来像这样:
My very simple PHP call looks like this:
$client = new SoapClient('http://localhost:8080/calculator?wsdl', array('trace' => 1));
echo 'Sum: '.$client->addValues(4, 5);
但是然后我得到一个致命错误:超出60秒的最大执行时间..."或一个未捕获的SoapFault异常:[WSDL] SOAP-ERROR:解析WSDL:无法从' http://localhost:8080/calculator?wsdl '...例外.
But then I either get a "Fatal error: Maximum execution time of 60 seconds exceeded..." or an "Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost:8080/calculator?wsdl' ..." exception.
我已经将PHP SoapClient()与其他Web服务进行了测试,它们可以正常工作.与PHP结合使用的JAX-WS RI是否存在已知问题,或者我没有看到的Web服务中存在错误?
I have tested the PHP SoapClient() with other web services and they work without any issues. Is there a known issue with JAX-WS RI in combination with PHP, or is there an error in my web service I didn't see?
我发现了此错误报告,但甚至更新到了PHP 5.3 .2不能解决问题.
I have found this bug report, but even updating to PHP 5.3.2 didn't solve the problem.
谁能告诉我该怎么办?顺便说一下,我在Windows 7 x64上运行的Java版本如下:
Can anyone tell me what to do? And by the way, my Java version running on Windows 7 x64 is the following:
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01, mixed mode)
推荐答案
如果超时,则表明php无法正确解析WSDL URL.您是否在WSDL网址上尝试过file_get_contents()/curl?也许尝试调用IP而不是localhost,看看情况如何.
If it times out it looks like php isn't able to resolve the WSDL URL properly. Have you tried a file_get_contents()/curl on the WSDL Url? Maybe try calling the IP instead of localhost and see how that goes.
这篇关于结合使用PHP SoapClient和Java JAX-WS RI(Webservice)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!