使用斜杠从 wsdl 生成 WebService 客户端

发布于 2024-12-27 14:22:59 字数 4200 浏览 4 评论 0原文

我的工具集由 Eclipse、CXF 2.5.1 和 OpenJDK 6 组成。

从 wsdl 生成 Web 客户端时,我收到包含斜杠的名称的错误:'soap/SomeService' 不是 'QName' 的有效值/'NCName'

用点替换该斜杠我可以生成客户端,但是(恢复后)我在调用服务时遇到异常。

我尝试用 %2F 替换斜杠,但这也不起作用。

源wsdl:

<wsdl:service name="soap/SomeService">
    <wsdl:port binding="impl:soap/SomeServiceSoapBinding" name="soap/SomeService">
        <wsdlsoap:address location="http://domain/axis/services/soap/SomeService"/>
    </wsdl:port>
</wsdl:service>

生成的soap服务文件:

@WebServiceClient(name = "soap/SomeService", 
                  wsdlLocation = "http://domain/axis/services/soap/SomeService?wsdl",
                  targetNamespace = "http://soap.some.service.net") 
public class SoapSomeService extends javax.xml.ws.Service {

    public final static URL WSDL_LOCATION;

    public final static QName SERVICE = new QName("http://soap.some.service.net", "soap/SomeService");
    public final static QName SoapSomeService = new QName("http://soap.some.service.net", "soap/SomeService");
    static {
        URL url = null;
        try {
            url = new URL("http://domain/axis/services/soap/SomeService?wsdl");
        } catch (MalformedURLException e) {
            java.util.logging.Logger.getLogger(SoapSomeService.class.getName())
                .log(java.util.logging.Level.INFO, 
                     "Can not initialize the default wsdl from {0}", "http://domain/axis/services/soap/SomeService?wsdl");
        }
        WSDL_LOCATION = url;
    }
    ...

堆栈跟踪:

Caused by: javax.xml.ws.WebServiceException: Illegal endpoint address: ${endpoint.servicemanager}
    at com.sun.xml.internal.ws.api.EndpointAddress.create(EndpointAddress.java:133)
    at com.sun.xml.internal.ws.client.RequestContext.setEndPointAddressString(RequestContext.java:143)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at com.sun.xml.internal.ws.api.PropertySet$MethodAccessor.set(PropertySet.java:285)
    at com.sun.xml.internal.ws.api.PropertySet.put(PropertySet.java:345)
    at com.sun.xml.internal.ws.client.RequestContext.put(RequestContext.java:254)
    at com.sun.xml.internal.ws.client.RequestContext$MapView.put(RequestContext.java:352)
    at com.sun.xml.internal.ws.client.RequestContext$MapView.put(RequestContext.java:311)
    at ecard.gina.soap.SoapServiceManager.init(SoapServiceManager.java:27)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:346)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:299)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:132)
    ... 30 more
Caused by: java.net.URISyntaxException: Illegal character in path at index 1: ${endpoint.servicemanager}
    at java.net.URI$Parser.fail(URI.java:2825)
    at java.net.URI$Parser.checkChars(URI.java:2998)
    at java.net.URI$Parser.parseHierarchical(URI.java:3082)
    at java.net.URI$Parser.parse(URI.java:3040)
    at java.net.URI.<init>(URI.java:595)
    at com.sun.xml.internal.ws.api.EndpointAddress.<init>(EndpointAddress.java:115)
    at com.sun.xml.internal.ws.api.EndpointAddress.create(EndpointAddress.java:131)
    ... 48 more

My toolset consists of Eclipse, CXF 2.5.1 and OpenJDK 6.

While generating a webclient from a wsdl I get errors referring to its name which contains a slash: 'soap/SomeService' is not a valid value for 'QName' / 'NCName'.

Replacing that slash with a dot I can generate the client but (after reverting that) I get an exception while invoking the service.

I tried to replace the slash with %2F but that didn't work either.

The source wsdl:

<wsdl:service name="soap/SomeService">
    <wsdl:port binding="impl:soap/SomeServiceSoapBinding" name="soap/SomeService">
        <wsdlsoap:address location="http://domain/axis/services/soap/SomeService"/>
    </wsdl:port>
</wsdl:service>

The generated soap service file:

@WebServiceClient(name = "soap/SomeService", 
                  wsdlLocation = "http://domain/axis/services/soap/SomeService?wsdl",
                  targetNamespace = "http://soap.some.service.net") 
public class SoapSomeService extends javax.xml.ws.Service {

    public final static URL WSDL_LOCATION;

    public final static QName SERVICE = new QName("http://soap.some.service.net", "soap/SomeService");
    public final static QName SoapSomeService = new QName("http://soap.some.service.net", "soap/SomeService");
    static {
        URL url = null;
        try {
            url = new URL("http://domain/axis/services/soap/SomeService?wsdl");
        } catch (MalformedURLException e) {
            java.util.logging.Logger.getLogger(SoapSomeService.class.getName())
                .log(java.util.logging.Level.INFO, 
                     "Can not initialize the default wsdl from {0}", "http://domain/axis/services/soap/SomeService?wsdl");
        }
        WSDL_LOCATION = url;
    }
    ...

The stack trace:

Caused by: javax.xml.ws.WebServiceException: Illegal endpoint address: ${endpoint.servicemanager}
    at com.sun.xml.internal.ws.api.EndpointAddress.create(EndpointAddress.java:133)
    at com.sun.xml.internal.ws.client.RequestContext.setEndPointAddressString(RequestContext.java:143)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at com.sun.xml.internal.ws.api.PropertySet$MethodAccessor.set(PropertySet.java:285)
    at com.sun.xml.internal.ws.api.PropertySet.put(PropertySet.java:345)
    at com.sun.xml.internal.ws.client.RequestContext.put(RequestContext.java:254)
    at com.sun.xml.internal.ws.client.RequestContext$MapView.put(RequestContext.java:352)
    at com.sun.xml.internal.ws.client.RequestContext$MapView.put(RequestContext.java:311)
    at ecard.gina.soap.SoapServiceManager.init(SoapServiceManager.java:27)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:346)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:299)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:132)
    ... 30 more
Caused by: java.net.URISyntaxException: Illegal character in path at index 1: ${endpoint.servicemanager}
    at java.net.URI$Parser.fail(URI.java:2825)
    at java.net.URI$Parser.checkChars(URI.java:2998)
    at java.net.URI$Parser.parseHierarchical(URI.java:3082)
    at java.net.URI$Parser.parse(URI.java:3040)
    at java.net.URI.<init>(URI.java:595)
    at com.sun.xml.internal.ws.api.EndpointAddress.<init>(EndpointAddress.java:115)
    at com.sun.xml.internal.ws.api.EndpointAddress.create(EndpointAddress.java:131)
    ... 48 more

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文