【问题标题】:SOAP message using namespaces使用命名空间的 SOAP 消息
【发布时间】:2013-11-18 17:08:11
【问题描述】:

我们正在设计一个由外部系统调用的 Web 应用程序。我们将从如下所示的外部系统接收 Web 服务:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tis="http://schemas.tis.com/1.2/" xmlns:der="http://schemas.tis.com/DataProvisioning/">
   <soapenv:Header>
      <tis:SessionId>99999999</tis:SessionId>
   </soapenv:Header>
 <soapenv:Body>
  <tis:Create>
     <tis:MOType>SPPM@http://schemas.tis.com/DataProvisioning/</tis:MOType>
     <tis:MOId>
           <der:codex>12345677</der:msisdn>
     </tis:MOId>

     <tis:MOAttributes>
        <der:createSPDD ProfileID="1"  Action="createData">

           <der:TechProduct Action="add" BarCode="15">
            <der:Arguments ArgName="arg1" ArgType="string" ArgValue="1"></der:Arguments>
            <der:Arguments ArgName="arg3" ArgType="string" ArgValue="2"></der:Arguments>
           </der:TechProduct>
           <der:TechProduct Action="delete" BarCode="21">
            <der:Arguments ArgName="arg1" ArgType="string" ArgValue="1"></der:Arguments>
            <der:Arguments ArgName="arg3" ArgType="string" ArgValue="2"></der:Arguments>
           </der:TechProduct>
        </der:createSPDD>
     </tis:MOAttributes>
  </tis:Create>

如您所见,我们将收到的这个 SOAP Envelope 中包含命名空间。到目前为止,我的 Web 服务应用程序已使用 JAX-WS 和自下而上的方法进行编码(只需将 @WebService 和 @WebMethod 注释添加到类中)。设计需要基于名称空间接收消息的 Web 服务的正确方法是什么?我应该先设计 WSDL 吗?我看不到如何收集 Header 或 Body 中的属性,例如 MoType 或 MoId。有什么帮助吗?
非常感谢

【问题讨论】:

    标签: web-services soap wsdl jax-ws


    【解决方案1】:

    根据您的问题,很难理解您是要公开 Web 服务还是要使用 Web 服务。如果您想公开具有这种结构和名称空间的 Web 服务,您可以选择自下而上或自上而下的方法。您将使用自上而下的方法创建

    1. WSDL(这里显然可以提及服务相关细节的命名空间)
    2. 架构(定义请求和响应元素的命名空间)
    3. 从 WSDL 和 Schema 生成 Java 类。
    4. 编写 Web 服务接口的实现。

    如果您想使用该服务,则无需编写任何 WSDL。从服务提供者处获取 WSDL 和 Schema(如果有),从收到的 WSDL 和 Schema 生成 Java 类。您不必担心基于名称空间读取值,jaxws 框架会为您完成。

    Google 使用 jaxws 服务的步骤。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-24
      • 1970-01-01
      • 2013-05-27
      • 2013-03-15
      相关资源
      最近更新 更多