我现在正在阅读JAX-WS.
我已经使用Eclipse和手工成功构建了JAX-WS RI服务.这两种方法都使用了apt.在通过Eclipse将应用程序部署到应用程序服务器或创建战争(使用或不使用sun-jaxws.xml,具体取决于正在使用的容器)并手动部署它时,JAX-WS运行时生成相应的WSDL自动.
什么时候使用wsgen很有用?
我有一个由jax-ws生成的wsdl文件.是否有可能将它与"Axis2 wsdl-to-java"生成的java代码一起使用?
因为我得到了这个例外;
java.lang.InstantiationError: org.apache.axis2.databinding.ADBDataSource
at tr.com.turkcell.radius.IPToDataWithPortServiceStub$TSO_DATA.getOMElement(IPToDataWithPortServiceStub.java:5751)
at tr.com.turkcell.radius.IPToDataWithPortServiceStub.toEnvelope(IPToDataWithPortServiceStub.java:7826)
at tr.com.turkcell.radius.IPToDataWithPortServiceStub.process(IPToDataWithPortServiceStub.java:167)
at com.ericsson.enk.mtv.authentication.radius.RadiusService.callRadiusWS(RadiusService.java:100)
at com.ericsson.enk.mtv.authentication.radius.RadiusService.authenticate(RadiusService.java:62)
at com.ericsson.enk.mtv.plugin.authentication.RadiusAuthenticationPlugin.processDefaultAuthenticationRequest(RadiusAuthenticationPlugin.java:137)
at com.ericsson.enk.mtv.plugin.authentication.RadiusAuthenticationPlugin.authenticate(RadiusAuthenticationPlugin.java:96)
at com.ericsson.mtv.bric.bl.AuthenticationBusinessDelegateImpl.authenticate(AuthenticationBusinessDelegateImpl.java:244)
at com.ericsson.mtv.bric.bl.AuthenticationBusinessDelegateImpl.authenticate(AuthenticationBusinessDelegateImpl.java:88)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.service.ServiceContainer.dynamicInvoke(ServiceContainer.java:376)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:81)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) …Run Code Online (Sandbox Code Playgroud) 我正在使用带有maven 3的netbeans.当我尝试使用jaxws-maven-plugin进行编译时,我收到以下错误.
这是我的pom
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<id>teamWS</id>
<goals>
<goal>wsgen</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<resourceDestDir>${project.build.directory}/classes/wsdl</resourceDestDir>
<sei>xyz.timerserver.server.TimeServer</sei>
<genWsdl>true</genWsdl>
<keep>true</keep>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
</dependency>
<dependency>
<groupId>javax.jws</groupId>
<artifactId>jsr181-api</artifactId>
<version>1.0-MR1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误消息.我试图使用系统范围依赖添加tools.jar但仍然没有运气
Failed to execute goal org.codehaus.mojo:jaxws-maven-plugin:1.10:wsgen (teamWS) on project JWSServer: Failed to execute wsgen: com/sun/mirror/apt/AnnotationProcessorFactory: com.sun.mirror.apt.AnnotationProcessorFactory -> [Help 1]
Run Code Online (Sandbox Code Playgroud) 我有一个来自Axis2 Web服务的WSDL文件.当我使用wsimport给定WSDL文件生成客户端存根时,生成的类需要JAXBElement参数.为什么会那样?
来自其中一个生成类的示例方法:
JAXBElement<DataBean> value;
public void setValue(JAXBElement<DataBean> value)
{
this.value = ((JAXBElement<DataBean>) value);
}
Run Code Online (Sandbox Code Playgroud)
我希望它看起来像这样(没有JAXBElement):
DataBean value;
public void setValue(DataBean value)
{
this.value= (DataBean) value;
}
Run Code Online (Sandbox Code Playgroud)
我在网上看到的教程没有将类设置为JAXBElement.可能是什么问题呢?请注意,服务器是Axis2 Web服务,WSDL文件由Axis2自动生成.假设是我无法控制服务器.
如何以wsimport不将参数转换为JAXBElements 的方式创建它?
以下是WSDL文件的摘录:(我忽略了一些标签只包含必要的标签)
<xs:element name="getData">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="getData" nillable="true" type="ax220:getData"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="getData">
<xs:sequence>
<xs:element minOccurs="0" name="value" nillable="true" type="ax219:DataBean"/>
</xs:sequence>
</xs:complexType>
<wsdl:message name="getDataRequest">
<wsdl:part name="parameters" element="ns:getData"/>
</wsdl:message>
<wsdl:message name="getDataResponse">
<wsdl:part name="parameters" element="ns:getDataResponse"/>
</wsdl:message>
<wsdl:operation name="getData">
<wsdl:input message="ns:getDataRequest" wsaw:Action="urn:getData"/>
<wsdl:output message="ns:getDataResponse" wsaw:Action="urn:getDataResponse"/> …Run Code Online (Sandbox Code Playgroud) 我是否可以使用JAX-WS(wsimport)生成的客户端存根连接到JAX-RPC Web服务?使用JAX-WS客户端使用JAX-RPC Web服务有什么影响?有什么优点和缺点吗?
你能解释一下SOAPHandler接口的getHeaders方法到底应该做什么吗?
http://docs.oracle.com/javaee/5/api/javax/xml/ws/handler/soap/SOAPHandler.html#getHeaders%28%29
我不确定它是否会创建额外的标头,或者它是否应该告诉运行时消息应该具有哪些标头.
我一直在扫描互联网寻找详细信息,但我找不到任何.我认为是如此基本和明显,不需要文档LOL :-)
谢谢
我在客户端创建了一个SOAPHandler来记录对服务器的传出请求,并在SOAP消息中添加了一个SOAP头.它正在记录没有头部分的传出soap xml.但是在服务器端我可以用soap记录整个消息头.
服务器端日志:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<Credential xmlns="http://soap.header.test.com" password="123" username="ashok"/>
</SOAP-ENV:Header>
<S:Body>
<ns2:addNumber xmlns:ns2="http://service.ashok.com/">
<arg0>10</arg0>
<arg1>200</arg1>
</ns2:addNumber>
</S:Body>
Run Code Online (Sandbox Code Playgroud)
客户端日志
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/> **NO HEADER**
<S:Body>
<ns2:addNumber xmlns:ns2="http://service.ashok.com/">
<arg0>10</arg0>
<arg1>200</arg1>
</ns2:addNumber>
</S:Body>
Run Code Online (Sandbox Code Playgroud)
我在客户端的部分SOAPHandler
if (outgoingRequest) {
SOAPMessage message = context.getMessage();
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
SOAPHeader header = envelope.getHeader();
if (null == header) {
header = envelope.addHeader();
}
QName credential = new QName("http://soap.header.test.com","Credential");
SOAPHeaderElement headerElement = header.addHeaderElement(credential);
QName username = new QName("username");
headerElement.addAttribute(username, "ashok");
QName password = new QName("password");
headerElement.addAttribute(password, …Run Code Online (Sandbox Code Playgroud) 我在Java EE 7应用程序中实现JAX-WS服务时遇到以下异常.
Warning: Internal Server error: /Test-war/Test.xhtml
java.lang.NullPointerException
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:272)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:745)
Run Code Online (Sandbox Code Playgroud)
异常消息似乎非常特定于GlassFish Server(我正在使用4.1).
测试场景:
CDI托管bean:
@Named
@ViewScoped
public class TestManagedBean implements Serializable
{
private String test;
private static final long serialVersionUID=1L;
public TestManagedBean() {}
@PostConstruct
private void init() {
TestBean_Service testBean_Service=new TestBean_Service(); …Run Code Online (Sandbox Code Playgroud) 我已经搜索了很多,以找到Web服务中使用的BindingProvider的具体解释,但我可以获得完整的信息.
我还阅读了官方文档,但我仍然对BindingProvider背后的概念感到困惑.官方文件说
4.2 javax.xml.ws.BindingProvider
BindingProvider接口表示一个组件,它提供供客户端使用的协议绑定,它由代理实现,并由Dispatch接口扩展.
在docs中,Protocol Binding是什么意思?
你们可以借助简单的代码帮助我理解什么是BindingProvider及其目的.
使用Eclipse时,我可以使用JAX-WS批注(例如@WebService),而无需包含任何外部依赖项,但是我不能对JAX-RS批注(例如@Path)进行相同的操作。我看了一下这个答案,我知道这javax.ws.rs不是JDK的一部分。为什么JAX-WS是JDK的一部分而JAX-RS不是呢?其次,如果我在GlassFish或WildFly服务器上部署带有JAX-WS注释的应用程序,该服务器是否使用众所周知的WebService堆栈来运行该应用程序(例如Metro)或它自己的实现?