我正在创建一个web服务。我想知道如何声明参数类型并将其用作Java类型。日期。我已经用Java编写了客户端来使用web服务,它工作得很好,但我想知道我是否可以使用用其他语言编写的客户端来使用相同的web服务。我给你一个我的web服务的代码示例:
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.xml.ws.Endpoint;
@WebService
public class WiseQuoteServer {
@SOAPBinding(style = Style.RPC)
public String getQuote(String category) {
if (category.equals("fun")) {
return "5 is a sufficient approximation of infinity.";
}
if (category.equals("work")) {
return "Remember to enjoy life, even during difficult situatons.";
} else {
return "Becoming a master is relatively easily. Do something well and then continue to do it for the next 20 years";
}
}
public static void main(String[] args) {
WiseQuoteServer server = new WiseQuoteServer();
Endpoint endpoint = Endpoint.publish(
"http://localhost:9191/wisequotes", server);
}
}发布于 2011-04-23 02:09:19
Jigar是正确的。JAX-WS使用JAXB将参数转换为XML。JAXB有一组广泛的注释,您可以使用这些注释来自定义如何将数据转换为XML。由于数据是以XML格式发送的,因此几乎任何语言都可以对服务进行读/写操作。此外,大多数语言都有某种SOAP库可用。
https://stackoverflow.com/questions/5758382
复制相似问题