更新 2
我可能不明白你的问题。(你能提供你的服务的 wdsl 吗?)创建一个像你的 php 代码一样的客户端:
利用:
package com.mkyong.client;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import com.mkyong.ws.HelloWorld;
public class HelloWorldClient{
public static void main(String[] args) throws Exception {
URL url = new URL("http://localhost:9999/ws/hello?wsdl");
//1st argument service URI, refer to wsdl document above
//2nd argument is service name, refer to wsdl document above
QName qname = new QName("http://ws.mkyong.com/", "HelloWorldImplService");
Service service = Service.create(url, qname);
HelloWorld hello = service.getPort(HelloWorld.class);
System.out.println(hello.getHelloWorldAsString("mkyong"));
}
}
将此文件复制到 com/mkyong/client。要编译 usejavac com/mkyong/client/HelloWorldClient.java
并运行 use java com/mkyong/client/HelloWorldClient
,另请参阅:Compiling Four java files within one package using javac and making a java package in the command line
“映射”到您的php 示例http://localhost:9999/ws/hello?wsdl
将等同于.http://hostname:port/
executeCommand
hello.getHelloWorldAsString
更新尝试 JAX-WS ( http://jax-ws.java.net/ )
来自http://www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example/:
package com.mkyong.ws;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
//Service Endpoint Interface
@WebService
@SOAPBinding(style = Style.RPC)
public interface HelloWorld{
@WebMethod String getHelloWorldAsString(String name);
}
除了这里的答案:Working Soap client example,您可以找到许多教程,告诉您如何在 java 中编写一个 soap 客户端: