• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 17,  comments - 2,  trackbacks - 0
            October 09

            gSoap: How to add info to SOAP Header using gSOAP

            gSoap: How to add info to SOAP Header using gSOAP
            There's some misleading info in gSOAP's official documents in SOAP Header Processing Part. 
            This article leads you to the right way and can make your program work.
            The use case is: 
            Client needs to pass user name and password to Server Side to get authenticated.
            The username and password info should be embeded in SOAP Header.
            Steps:
            1. Edit struct SOAP_ENV__Header in soapStub.h file which is generated by gSOAP's soapcpp2 compiler
            Add the neccesary info to this struct 
            For example:
            The original one is:
            struct SOAP_ENV__Header
            {
            public:
             void *dummy; /* transient */
            };
            This should be changed to:
            struct SOAP_ENV__Header
            {
            public:
             void *dummy; /* transient */
             char *username;
             char *password;
            };
            2.  Edit function soap_out_SOAP_ENV__Header in soapC.cpp file which is also generated by gSOAP
            Add statements to serialize those info into SOAP Header.
            For example:
            The original one is:
            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_element_end_out(soap, tag);
                return SOAP_OK;
            }
            This could be changed to:
            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, "headerNS:username", 1, &(a->username), "");
                soap_out_string(soap, "headerNS:password", 2, &(a->password), "");
                soap_element_end_out(soap, tag);
                return SOAP_OK;
            }
            3. Add the namespace mapping to namespaces array in .nsmap file.
             {"headerNS", "http://customeheader.test.com", NULL, NULL},
             
            4. Set the header before invoking Web Service Method. This part you can also refer to the gSOAP's official documenthttp://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc12.
               struct soap soap; 
               soap_init(&soap);  
            ...
                soap->header = (SOAP_ENV__Header *)soap_malloc(soap, sizeof(SOAP_ENV__Header));
                soap->header->username = (char*)malloc(MAX_NAME_SIZE * sizeof(char));
                soap->header->password = (char*)malloc(MAX_NAME_SIZE * sizeof(char));
                strcpy(soap->header->username, username);
                strcpy(soap->header->password, passwd);
                soap_call_method(&soap, ...);  //the SOAP Header will be in the request
            ...
            5. Compile
            6. Run. 
            The SOAP Message could be
            ... 
            <SOAP-ENV:Envelope xmlns:headerNS="
            http://customeheader.vpamws.com">
            <SOAP-ENV:Header>
            <headerNS:username>admin</headerNS:username>
            <headerNS:password>default</headerNS:password>
            </SOAP-ENV:Header>
            <SOAP-ENV:Body> 
            ... 
            </SOAP-ENV:Body> 
            </SOAP-ENV:Envelope>
             
            Any Questions, Please let me know. Thanks.
             
            -Debora
            posted on 2009-03-28 15:29 BeyondCN 閱讀(1187) 評論(0)  編輯 收藏 引用
            久久综合久久综合九色| 久久久久亚洲?V成人无码| 久久人人爽人人爽人人片AV东京热| 久久久久女教师免费一区| 久久午夜免费视频| 久久精品嫩草影院| 久久天天躁狠狠躁夜夜2020老熟妇| 国产成人无码精品久久久免费| 性做久久久久久免费观看| 中文字幕无码精品亚洲资源网久久 | 欧美日韩精品久久久久 | 久久综合鬼色88久久精品综合自在自线噜噜| 久久精品国产清自在天天线| 一本色道久久综合狠狠躁| 99久久精品免费观看国产| 国产亚洲精久久久久久无码77777 国产亚洲精品久久久久秋霞 | 一本色道久久88综合日韩精品 | 日韩精品久久久肉伦网站 | 亚洲精品无码久久千人斩| 亚洲综合久久综合激情久久| 久久久一本精品99久久精品88| 99久久国产热无码精品免费久久久久 | 久久婷婷五月综合色奶水99啪| 亚洲天堂久久精品| 亚洲精品午夜国产VA久久成人| 久久久久久极精品久久久| 精品免费tv久久久久久久| 久久亚洲精品中文字幕| 精品国产乱码久久久久久人妻| 久久久久人妻一区精品| 久久亚洲国产午夜精品理论片 | 波多野结衣中文字幕久久| 波多野结衣久久精品| 亚洲日韩欧美一区久久久久我| 伊人色综合久久| 国产精品99久久不卡| 国产精品久久久天天影视香蕉| 99久久婷婷国产综合精品草原| 国产国产成人精品久久| 久久夜色精品国产亚洲| 国产精品亚洲美女久久久|