`

Soap Header收藏 Soap Header

阅读更多

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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics