java - Intellij 生成的 WSDL 客户端代码

标签 java web-services intellij-idea wsdl jax-ws

我正在尝试让客户端连接到 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/

相关文章:

intellij-idea - IntelliJ IDEA 部署后 Wildfly 无法加载部署

c# - 来自 c# asmx 的 JSON 返回转义字符串格式而不是 JSON 对象

java - 我该如何实现以下内容?

git - 使用备用帐户在 GitHub 上共享项目

regex - sql 文件中的小写脚本

web-services - Get 和 post 方法与 HTTP 和 REST 的区别

java - 将多行 JTextArea 写入 txt 文件

Java - 将值从子类发送到父类(super class)

java - 同步块(synchronized block)和 while 循环优化排序

java - 仅从字符串标签中提取值