在JAX-WS中定义绑定名称 [英] Define binding name in JAX-WS

查看:66
本文介绍了在JAX-WS中定义绑定名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个JAX-WS WebService,我现在需要定义一个自定义的Binding名称,因为它被定义为端口名称并附加了"Binding".

I'm developing a JAX-WS WebService and I currently need to define a custom Binding name, since it gets defined as the Port name with "Binding" appended to it.

例如:如果 Port 名称为 MyJAXService ,则 Binding 名称默认情况下将为 MyJAXServiceBinding .我想要的是 Binding 名称类似于 MyJAXService .

E.g.: If the Port name is MyJAXService the Binding name is going to be MyJAXServiceBinding by default. What I wanted was for the Binding name to be something else like MyJAXService.

我的Web服务具有如下定义的@WebService注释

My web service has the @WebService annotation defined as follows

@WebService(serviceName = "MyJAXService", portName = "MyJAXService", endpointInterface = "com.test.MyJAXService", targetNamespace = "http://test.local/")

推荐答案

我想您正在使用 Java到WSDL的方法,因此,您希望从工件中生成WSDL.

I suppose that you are using the Java to WSDL approach so, you want to generate the WSDL from your artifacts.

我通常使用另一种方法,即Java的WSDL,对于类似WSDL的方法:

I usually use the other approach, WSDL to Java and, for a WSDL like:

<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns="http://mynamespace" xmlns="http://schemas.xmlsoap.org/wsdl/"  targetNamespace="http://mynamespace">
  ...
  <portType name="MySoapBinding">
    <operation name="MyOperation">
        ...
    </operation>
  </portType>
  <binding name="MySoapBinding" type="ns:MySoapBinding">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="MyOperation">
        ...
    </operation>
  </binding>
  <service name="MyService">
    <port name="MySoapBinding" binding="ns:MySoapBinding">
      <soap:address location="http://localhost:8080/MyService"/>
    </port>
  </service>
</definitions>

生成的工件是一个接口:

The artifacts generated are, an interface:

@WebService(name = "MySoapBinding", targetNamespace = "http://mynamespace")
public interface MySoapBinding {
    ...
}

和实现:

@WebService(name = "MySoapBinding", targetNamespace = "http://mynamespace", endpointInterface = "my.package.MySoapBinding", serviceName = "MyService", portName = "MySoapBinding")
public class MySoapBindingImpl
    implements MySoapBinding
{
}

我想您可以尝试为Web服务的接口命名,并且生成的WSDL应该使用该名称作为 Binding 名称.

I guess that you can try to give a name to the interface of the web service and the WSDL generated should use that name as the Binding name.

这篇关于在JAX-WS中定义绑定名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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