Soap Header

生成的XML文本格式如下:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
- <soapenv:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Header>
  <ns1:username xmlns:ns1="Authorization">sysadmin</ns1:username>
  <ns2:password xmlns:ns2="Authorization">Amdocsls08</ns2:password>
  </soapenv:Header>
- <soapenv:Body>
- <ns1:invoke xmlns:ns1="http://server.webservice.core.epm" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <path>epm/cc/assistant/ctiactioninfo/service/CtiActionInfoService</path>
  <methodName>saveBatchCtiActionInfo</methodName>
  <dataXmlStr><?xml version='1.0' encoding='UTF-8'?><DBSET><R><C N="calledWorkNo">agent1</C><C N="calloutNo">agent1</C><C N="itemSrc">1</C><C N="itemId">1</C><C N="callId">01</C><C N="calledExetensionNo">01</C><C N="aniNo">agent1</C><C N="dnisNo">01</C><C N="recordId">01</C><C N="orgNo">3401</C><C N="queueNo">6601</C><C N="flowNo"></C><C N="workNo">agent</C><C N="exetensionNo">3001</C></R></DBSET></dataXmlStr>
  </ns1:invoke>
  </soapenv:Body>
  </soapenv:Envelope>

 

需额外生成的文本为红色标记部位...下面说下如何实现这个Soap Header的添加

 

在用gsoap工具编译生成的xxx.nsmp文件中加入红色标注代码

 

   xxxxxxSoapBinding.nsmap

 

#include "soapH.h"

SOAP_NMAC struct Namespace namespaces[] =

{

     {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope", NULL},

     {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/*/soap-encoding", NULL},

     {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},

     {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},

   {"ns1", "Authorization", NULL, NULL},

   {"ns2", "Authorization", NULL, NULL},

     {NULL, NULL, NULL, NULL}

};

 

   在 soapC.c中对soap_out_SOAP_ENV_Header()原型进行更改,添加红色标注部分代码.

 

SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type)

{

     soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Header), type);

     /* transient dummy skipped */

   soap_out_string(soap, "ns1:username", 1, &(a->username), "");

    soap_out_string(soap, "ns2:password", 2, &(a->password), "");

     soap_element_end_out(soap, tag);

     return SOAP_OK;

}

 

  在  soapStub.h中对结构体SOAP_ENV_Header添加2个成员.分别为char *username, char *password.

 

#ifndef SOAP_TYPE_SOAP_ENV__Header

#define SOAP_TYPE_SOAP_ENV__Header (18)

/* SOAP Header: */

struct SOAP_ENV__Header

{

     void *dummy;  /* transient */

   char *username;

   char *password;

};

#endif

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值