我找到了解決辦法。請參閱下面。
JaxWsPortProxyFactoryBean jaxWsPortProxyFactoryBean = new JaxWsPortProxyFactoryBean();
String URI = "http://localhost:8080/service";
try {
jaxWsPortProxyFactoryBean.setWsdlDocumentUrl(new URL(URI+"?wsdl"));
jaxWsPortProxyFactoryBean.setServiceInterface(myIService.class);
jaxWsPortProxyFactoryBean.setPortName(PORT);
jaxWsPortProxyFactoryBean.setNamespaceUri(URI);
jaxWsPortProxyFactoryBean.setServiceName(SERVICE_NAME);
logger.debug("WSDL - "+jaxWsPortProxyFactoryBean.getWsdlDocumentUrl());
jaxWsPortProxyFactoryBean.afterPropertiesSet();
} catch (Exception e) {
logger.error("Error occured while connecting to the TW web service -",e);
}
請參考Accessing web services using JAX-WS以獲取有關端口和URI的更多信息。
服務接口 -
public interface testService {
@WebMethod(operationName = "myOperations", action = "")
@WebResult(name = "errorCode",targetNamespace = "")
public String testWebService(
@WebParam(name = "studentId", targetNamespace = "", mode = Mode.IN) Integer studentId,
@WebParam(name = "studenName", targetNamespace = "", mode = Mode.IN) String studenName);
}
myOperations - 就是你需要在web服務訪問操作
的errorCode - 從web服務的返回值
studentId,studentName - 是的您需要發送到Web服務的參數。
我被卡住瞭如何找出將多個屬性映射爲webResults。我發佈了this的問題,仍然沒有任何運氣。
來源
2011-05-05 14:34:41
Sam