java - 手动处理 SOAP/JAX-WS 请求

标签 java jakarta-ee soap jax-ws

有没有办法手动或基于每个请求处理 SOAP 请求?由于现有系统中一些非常愚蠢的技术原因,我无法将 JAX-WS 服务发布到通过标准端点工厂创建的端点。我的情况有点困惑,因为我基本上从 ServerSocket 获得了一个原始的 InputStream 并被告知处理它。

流中的数据是从发出 SOAP 请求的客户端发送的。客户端的开发人员提供了一堆 WSDL 和 XSD,用于使用 wsimport 和 xjc 生成必要的服务器端类。所有这些都是 JAX-WS,我希望尽可能多地利用 JAX-WS 来最大限度地减少我必须做的工作。

有谁知道从哪里开始寻找如何做到这一点?有可能吗?目前我最好的猜测是我必须手动实现客户端点或提供商。

谢谢!

最佳答案

您可以通过以下步骤处理原始输入。只需像解析任何 XML 流一样解析传入消息

     try{ //throws a bunch of XML parsing related exceptions
      XMLInputFactory xFactory = XMLInputFactory.newFactory();
      XMLStreamReader xStream = xFactory.createXMLStreamReader(req.getInputStream());
      //Start skipping tags til you get to the message payload
      for(int nodeCount=0; nodeCount < 3; nodeCount++){
             xStream.nextTag(); //Jump <Envelope/>,<Body/>,<theMessageNode/>   
          }
      //You're now at the level of the actual class; Now unmarshal the payload  

      JAXBContext ctxt  = JAXBContext.newInstance(YourResponseClass.class);
      Unmarshaller um = ctxt.createUnmarshaller();
      JAXBElement<YourResponseClass.class> elem = um.unmarshal(xStream, YourResponseClass.class);             
      YourResponseClass theObj = elem.getValue();

     }
    catch(Exception ex) {

    }

关于java - 手动处理 SOAP/JAX-WS 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15014080/

相关文章:

java - 在 jre 中更新 gzip 库

java - 使用组和子复选框创建可扩展 ListView

java - Shiro 和 Tomcat AccessLogValve

java - Spring Security 和 Synchronizer Token J2EE 模式,身份验证失败时出现问题

.Net Web 引用 SSL 错误

xml - SOAP 响应的返回序列类型

java - 没有找到依赖 : expected at least 1 bean which qualifies as autowire candidate for this dependency. 依赖注释:

java - 运行 OSGI 框架时出现 bundle 异常

java - 多层在weblogic服务器JNDI查找中意味着什么

java - 禁用 HttpClient 日志记录