消息级别的Jax-WS服务 [英] Message level Jax-WS service

查看:51
本文介绍了消息级别的Jax-WS服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个WebService存根.我喜欢在一个地方响应所有请求.我有一个样本值生成器,它可以处理请求的类型并创建样本响应,因此我不需要具有很多类的代码生成对象.只是一个非常简单的.

I'm trying to create a WebService stub. I like to react to all of the request in one single place. I have a sample value generator, which handles the type of the request and creates a sample response, so I don't need the code-generation things with a lots of classes. Only a really simple one.

我发现 http://jax-ws.java .net/nonav/2.2.1/docs/provider.html WebServiceProvider恰好用于获取原始SOAP消息,并在单个位置创建响应.

I have found http://jax-ws.java.net/nonav/2.2.1/docs/provider.html WebServiceProvider which is exactly for getting raw SOAP messages, and create a response in a single place.

主要问题是我对这个神奇的EE世界是陌生的:),我还是无法启动WebServiceProvider示例.

The main problem is I'm new to this magical EE world :) and I simply can not start WebServiceProvider sample anyway.

我已经安装/配置了Spring,SpringSource ToolSuit,Axis,其他所有东西都在工作.

I have Spring, SpringSource ToolSuit, Axis installed/configured, all of the other things are working.

谢谢大家的帮助,如果问题对您来说太简单了,请原谅.也许我只是没有找到/读过一些东西. M.

Thank you all for your help, and please excuse me if the question is too simple for you. Maybe I just did not find/read something. M.

推荐答案

最后,我找到了解决方案(感谢同事的帮助). 如果您使用的是JAX-WS,则有一个简单的解决方案.

Finally I have found the solution (thanks for the help from my workmates). If you are using JAX-WS, there is a simple solution.

您的WEB-INF文件夹中需要包含以下内容的sun-jaxws.xml:

You need a sun-jaxws.xml in your WEB-INF folder containing the following:

<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">
  <endpoint
     name="RawWS"
     implementation="com.stg.pack.MyServiceProvider"

     url-pattern="/HotelServices200631"/>
</endpoints>  

并且您需要一个com.stg.pack.MyServiceProvider类,如下所示:

And you need a com.stg.pack.MyServiceProvider class which looks like:

package com.stg.pack;

@ServiceMode(value = Service.Mode.MESSAGE)
@WebServiceProvider(portName = "ThePortNameOfWebService", 
        serviceName = "TheNameOfWebService", 
        targetNamespace = "http://www.example.com/target/namespace/uri")
public class MyServiceProvider implements Provider<SOAPMessage> {

    @Override
    public SOAPMessage invoke(SOAPMessage request) {
        SOAPMessage result = null;
        // create response SOAPMessage
        return result;
    }
}

在我忘记之前,您需要在web.xml中定义一些内容:

And before I forget, you need to define some things in web.xml:

   <listener>
     <listener-class>
        com.sun.xml.ws.transport.http.servlet.WSServletContextListener
     </listener-class>
   </listener>
   <servlet>
      <servlet-name>RawWS</servlet-name>
      <servlet-class>
        com.sun.xml.ws.transport.http.servlet.WSServlet
      </servlet-class>

   </servlet>
   <servlet-mapping>
     <servlet-name>RawWS</servlet-name>
     <url-pattern>/TheNameOfWebService</url-pattern>
   </servlet-mapping>

如果您这样使用它,则所有请求均由invoke方法处理.

If you use it like this, all of the request are handled by the invoke method.

这篇关于消息级别的Jax-WS服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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