`

wsdl中添加soap:header元素

    博客分类:
  • cxf
阅读更多

我们在开发webservice的时候,经常会看到有些生成的wsdl文件中包含了<soap:header>节点元素,那么怎样在wsdl

文件中添加<soap:header>节点元素。

 

我们知道开发webservice服务其实有两种方式cxf发布有两种方式,一种Object first,也就是普通的方式,还有一种是

WSDLfirst,就是你自己编写WSDL文档然后发布。如果需要在生成的wsdl文件中包含soap:header元素,那么我们只

能采用第二种方式来开发webservice服务。

 

我将采用的是http://liuwuhen.iteye.com/blog/1666189 该博客中所产生的wsdl文件的基础,进行soap:header元

 素。

 

具体实现的步骤如下:

 

1.声明元素。

 

<xsd:element name="header" type="tns:headertype"/>
          <xsd:complexType name="headertype">
     <xsd:sequence>
      <xsd:element name="spPassword" type="xsd:string" />
      <xsd:element name="spId" type="xsd:int" />
     </xsd:sequence>
</xsd:complexType>

 

我们可以这样理解,其实xsd:element就相当于我们一个类中所对应的属性, xsd:complexType 可以理解为属性所对应

 

类型。

 

2. 在message节点处引用该头部元素

 

<wsdl:message name="sayHello">
    <wsdl:part element="tns:sayHello" name="parameters"/>
    <wsdl:part element="tns:header" name="header_info"/>
</wsdl:message>

 

其中 element="tns:header"引用的是上面声明的元素。

 

3.在wsdl:binding中的wsdl:operation处添加<soap:header>元素

 

<wsdl:operation name="sayHello">
   <soap:operation soapAction="" style="document" />
   <wsdl:input name="sayHello">
      <soap:header message="tns:sayHello"
     part="header_info" use="literal" wsdl:required="true"/>
    <soap:body use="literal" parts="sayHello"/>
   </wsdl:input>
   <wsdl:output name="sayHelloResponse">
    <soap:body use="literal" />
   </wsdl:output>
  </wsdl:operation>

 

其中part引用是message部分声明的节点名称,use=literal表示的是编码的方式.

 

4.修改发布服务的cxf配置文件。

 

<jaxws:endpoint id="helloWorld" implementor="com.liuwuhen.cxf.IHelloWorldImpl"
  address="/sayHello" wsdlLocation="WEB-INF/HelloWorld.wsdl">

 

wsdlLocation :即指定wsdl文件所在的路径。

 

通上述的三个步骤即可完成wsdl文件中添加soap:header节点元素,应该很简单。

 

分享到:
评论

相关推荐

    C#静态调用带有SoapHeader验证的WebService

    关于此代码的使用及相关配置,可以见此文:...代码开发时环境:Windows8.1、Visual Studio 2013、IIS8 注意:测试代码时,重新部署WebService服务且修改客户端测试程序的服务引用

    Web Services 教程

    SOAP Header 元素 32 SOAP Header 元素 32 actor 属性 33 mustUnderstand 属性 34 encodingStyle 属性 35 SOAP Body 元素 35 SOAP Body 元素 35 SOAP Fault 元素 36 SOAP Fault 元素 36 SOAP Fault 代码 37 SOAP ...

    wsdl2java源码-wcfextrasplus:一组有用的WCF扩展,包括SoapHeader支持、WSDL扁平化和文档等

    wsdl2java源码 WCFExtrasPlus WCFExtrasPlus 是一组有用的 WCF 扩展: SOAP 标头支持 支持将源代码 XML 注释集成到 WSDL 文档中 覆盖 SOAP 地址位置 URL 单一、扁平化的 WSDL 文件,以更好地与旧 SOAP 工具兼容 作为...

    SOAP UI Open Source Testing with SOAP UI

    SOAP UI Open Source Testing with SOAP UI, Abstract 5  Target User 5  Introduction 6  SOAP UI 6  Functional Testing 6  API 6  SOAP 6  REST 7  Request and response 7  Getting started ...

    Java调用php的webservice

    $server-&gt;wsdl-&gt;schemaTargetNamespace = 'urn:hellowsdl'; $server-&gt;register('hello', // method name array('name' =&gt; 'xsd:string'), // input parameters array('return' =&gt; 'xsd:string'), // output ...

    amadeus-ws-client:PHP Amadeus SOAP Web服务客户端库

    amadeus-ws-client:Amadeus GDS ... 会话管理-为Soap Header 2和Soap Header 4设置正确的SOAP标头。 支持Soap Header 4的所有功能,例如有状态和无状态消息。 根据提供的选项构建正确的请求消息:库试图在可能的情况

    [Web Service学习笔记]第1篇 SOAP的HelloWord实例

    里面只有这样几句话:“交易消息(包括请求和应答)是以XML格式表达的,包括两个部分:Message Header(消息头)与Service Content(交易业务内容)。” “接口协议使用HTTP协议,落地方为发起方提供访问的URL,发起方...

    php.ini-development

    ;;;;;;;;... 1.... 2.... 3.... 4.... 5.... 6.... The syntax of the file is extremely simple.... Section headers (e.g.... at runtime.... There is no name validation.... (e.g.... previously set variable or directive (e.g....

    超级有影响力霸气的Java面试题大全文档

     栈是一种线形集合,其添加和删除元素的操作应在同一段完成。栈按照后进先出的方式进行处理。 堆是栈的一个组成元素 22、forward 和redirect的区别  forward是服务器请求资源,服务器直接访问目标地址的URL,把...

    java 面试题 总结

    栈是一种线形集合,其添加和删除元素的操作应在同一段完成。栈按照后进先出的方式进行处理。 堆是栈的一个组成元素 19、forward 和redirect的区别 forward是服务器请求资源,服务器直接访问目标地址的URL,把那个URL...

    RESTful Web Services.rar

    WSDL 304 UDDI 309 Security 310 Reliable Messaging 311 Transactions 312 BPEL, ESB, and SOA 313 Conclusion 314 11. Ajax Applications as REST Clients.... . . . . . . 315 From AJAX to Ajax 315 ...

    ZendFramework中文文档

    10.1.2. 添加引号防止数据库攻击 10.1.3. 直接查询 10.1.4. 事务处理 10.1.5. 插入数据行 10.1.6. 更新数据行 10.1.7. 删除数据行 10.1.8. 取回查询结果 10.2. Zend_Db_Statement 10.2.1. Creating a ...

    源码 Dr.Bob’s Delphi Prism XE Development Essentials June 2011

    源码 8 References . 8 2. Language Features 9 Oxygene Compiler....Delphi Prism Projects and Namespaces 9 Methods ......Unnamed Constructors ................................................................

    JavaEE 5.0 Tutorial.pdf

    SOAP Transport Protocol ........................................................................................................... 52 WSDL Standard Format ...............................................

Global site tag (gtag.js) - Google Analytics