• <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 閱讀(1186) 評論(0)  編輯 收藏 引用
            伊人 久久 精品| 久久精品国产国产精品四凭| 久久久久99精品成人片| 久久精品国产亚洲5555| AV无码久久久久不卡蜜桃| 99久久综合狠狠综合久久止| 久久国产成人精品国产成人亚洲| 亚洲国产成人久久综合碰| 久久99热只有频精品8| 久久久久九九精品影院| 亚洲∧v久久久无码精品| 9191精品国产免费久久| 久久无码专区国产精品发布| 久久免费精品一区二区| 日韩精品久久久肉伦网站| 香蕉aa三级久久毛片| 综合网日日天干夜夜久久| 国内精品久久久久国产盗摄| 麻豆AV一区二区三区久久 | 亚洲嫩草影院久久精品| 久久久久亚洲AV成人网人人网站 | 久久精品国产亚洲AV无码偷窥| 国产精品热久久毛片| 久久久久久久尹人综合网亚洲| 99精品国产99久久久久久97 | 久久久久九九精品影院| 久久综合九色综合久99| 国产精品女同久久久久电影院 | 国产精品无码久久综合| 亚洲精品白浆高清久久久久久| 偷窥少妇久久久久久久久| 久久影视综合亚洲| 精品久久久久久无码人妻蜜桃| 久久婷婷国产麻豆91天堂| 久久男人Av资源网站无码软件| 久久久久久久久久久精品尤物 | 日韩欧美亚洲综合久久影院Ds | 少妇久久久久久被弄到高潮| 久久天天躁狠狠躁夜夜av浪潮| 久久久中文字幕日本| 亚洲精品tv久久久久久久久久|