我正在尝试让客户端连接到 Web 服务并在服务器上使用 SetFlight 方法。
环境是 Intellij Ultimate、Java 7 和 JAXWS。从 WSDL 生成类已经完成。
在生成的类中,我有两个服务:
@WebServiceClient(name = "FOService", targetNamespace = "http://temporaryuri.org.au/", wsdlLocation = "http://fovanil.com/FOService.svc?wsdl")
public class FOService
extends Service
{
private final static URL FOSERVICE_WSDL_LOCATION;
private final static WebServiceException FOSERVICE_EXCEPTION;
private final static QName FOSERVICE_QNAME = new QName("http://temporaryuri.org.au/", "FOService");
static {
...
以及 IFO 服务
@WebService(name = "IFOService", targetNamespace = "urn:fo.com.au/schema/common")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
ObjectFactory.class
})
public interface IFOService {
/**
*
* @param parameters
* @return
* returns svc.SetFlightResponse
*/
@WebMethod(operationName = "SetFlight", action = "http://fo.com.au/SetFlight")
@WebResult(name = "SetFlightResponse", targetNamespace = "urn:fo.com.au/schema/common/types", partName = "parameters")
public SetFlightResponse SetFlight(
@WebParam(name = "SetFlightRequest", targetNamespace = "urn:fo.com.au/schema/common/types", partName = "parameters")
SetFlightRequest parameters);
}
我查看了一些实现客户端的示例 https://docs.oracle.com/javaee/5/tutorial/doc/bnayn.html然而这有所不同。
我原以为使用它会是:
IFOSerice service = new IFOService();
service.SetFlight(someinstanceofflight); //setFlight is not a available method
如何创建客户端并使用 SetFlight 方法?
最佳答案
此代码有效:
SetFORequest request = new SetFORequest();
SetFOResponse response = new SetFOResponse();
request.setFO(flight);
FOService foService = new FOService();
IfoService ifoService = foService.getWSHttpBindingIFOService();
ifoService.setFO(request);
关于java - Intellij 生成的 WSDL 客户端代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47820118/