当生成一个Apache CXF的客户,为什么实例化客户端时,仍然需要WSDL? [英] When generated an Apache CXF client, why is the WSDL still needed when instantiating the client?

查看:198
本文介绍了当生成一个Apache CXF的客户,为什么实例化客户端时,仍然需要WSDL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想消费SOAP服务,但在WSDL离线提供给我,从而导致客户端,与本地路径的WSDL生成

I want to consume a SOAP service but the WSDL is provided to me offline, thus resulting in the client being generated with the local path to the WSDL.

public class SoSo extends Service {
    public final static URL WSDL_LOCATION;
    public final static QName SERVICE = new QName("http://tempuri.org/", "SoSo");
    public final static QName SoSoSoap12 = new QName("http://tempuri.org/", "SoSoSoap12");
    public final static QName SoSoSoap = new QName("http://tempuri.org/", "SoSoSoap");
    static {
        URL url = null;
        try {
            url = new URL("file:/c:/Dev/Java/workspace/service-individualreport/src/main/resources/wsdl/SoSo.wsdl");
        } catch (MalformedURLException e) {
            java.util.logging.Logger.getLogger(SoSo.class.getName())
                .log(java.util.logging.Level.INFO, 
                 "Can not initialize the default wsdl from {0}", "file:/c:/Dev/Java/workspace/service-individualreport/src/main/resources/wsdl/SoSo.wsdl");
    }
    WSDL_LOCATION = url;
}

从我的角度来看,我想只有建立WSDL一次,然后指定服务的位置。

From my point of view I would like to only build the WSDL once and then specify the location of the service.

推荐答案

情侣部分这样的问题:

1)每JAX-WS规范,产生的code没有的所有的所需的请求信息。因此,在技术上需要的WSDL。随着CXF,你可以通过空的WSDL URL,然后使用((BindingProvider)端口).getRequestContext()把(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,HTTP://本地主机/ ......)设置处理和对许多用例,它将工作

1) Per JAX-WS spec, the generated code doesn't have ALL the information needed for the request. Thus, the wsdl is technically needed. With CXF, you CAN pass "null" for the wsdl URL and then use the ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost/....") to set the address and for many use cases, it will work.

2)WSDL2Java工具确实有可用于产生具有特定位置的服务对象-wsdlLocation标志。 -wsdlLocation应该导致没有烧入code。在code不会真的是便携式然后虽然。 (JAXWS RI /地铁需要WSDL)

2) The wsdl2java tool does have a -wsdlLocation flag that can be used to generate service objects with specific locations. -wsdlLocation "" should result in nothing burned into the code. The code wouldn't really be portable then though. (JAXWS ri/metro requires the wsdl)

这篇关于当生成一个Apache CXF的客户,为什么实例化客户端时,仍然需要WSDL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆