• <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>

            Codejie's C++ Space

            Using C++

            GSOAP:添加FAULT的處理

            不知道是WSDL描述還是GSOAP自身的問題,有其生成的代碼中在不支持Header的情況下,一樣不支持對FAULT處理,于是,照著處理Header的過程,添加了對FAULT的處理。
            ???? 為處理FAULT,需要事先知道SOAP報文中將FAULT信息放在哪里,當然了,一般自定義擴充都放在DETAIL里面。只是開始不太確定,于是還特意發了個錯誤報文給對端,收到如下回復,從而確認猜測是對的,這樣就可以修改了。

            <?xml?version='1.0'?encoding='utf-8'?><soapenv:Envelope?xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header?/><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>Authentication?Failed?AccessCfgHelper.getProductInfor(productId)?is?empty?or?is?null..</faultstring><detail><ns2:ServiceException?xmlns:ns2="http://www.chinatelecom.com.cn/schema/ctcc/common/v2_1"><messageId>SVC0901</messageId><text>CP/SP?authenticate?access?failed:Authentication?Failed?AccessCfgHelper.getProductInfor(productId)?is?empty?or?is?null..</text></ns2:ServiceException></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>


            ??? 首先在Detail結構里面添加所需要的Fault類型:
            #ifndef?SOAP_TYPE_SOAP_ENV__Detail
            #define?SOAP_TYPE_SOAP_ENV__Detail?(90)
            /*?SOAP-ENV:Detail?*/
            struct?SOAP_ENV__Detail
            {
            public:
            ????
            //int?__type;????/*?any?type?of?element?<fault>?(defined?below)?*/
            ????
            //void?*fault;????/*?transient?*/
            ????
            //char?*__any;

            ????sms2__ServiceException?
            *serviceException;
            ????sms2__PolicyException?
            *policyException;
            };
            #endif

            ??? 然后就是一樣修改Detail的in和out函數了:
            SOAP_FMAC3?int?SOAP_FMAC4?soap_out_SOAP_ENV__Detail(struct?soap?*soap,?const?char?*tag,?int?id,?const?struct?SOAP_ENV__Detail?*a,?const?char?*type)
            {
            ????
            if?(soap_element_begin_out(soap,?tag,?soap_embedded_id(soap,?id,?a,?SOAP_TYPE_SOAP_ENV__Detail),?type))
            ????????
            return?soap->error;
            ????
            //if?(soap_putelement(soap,?a->fault,?"fault",?-1,?a->__type))
            ????
            //????return?soap->error;
            ????
            //soap_outliteral(soap,?"-any",?&a->__any,?NULL);

            ????
            if(a?!=?NULL)
            ????{
            ????????
            if(a->serviceException?!=?NULL)
            ????????????a
            ->serviceException->soap_out(soap,?"sms2:ServiceException",?-1,?"");
            ????????
            else?if(a->policyException?!=?NULL)
            ????????????a
            ->policyException->soap_out(soap,?"sms2:PolicyException",?-1,?"");
            ????}

            ????
            return?soap_element_end_out(soap,?tag);
            }

            SOAP_FMAC3?struct?SOAP_ENV__Detail?*?SOAP_FMAC4?soap_in_SOAP_ENV__Detail(struct?soap?*soap,?const?char?*tag,?struct?SOAP_ENV__Detail?*a,?const?char?*type)
            {
            ????
            //size_t?soap_flag_fault?=?1;
            ????
            //size_t?soap_flag___any?=?1;
            ????if?(soap_element_begin_in(soap,?tag,?0,?type))
            ????????
            return?NULL;
            ????a?
            =?(struct?SOAP_ENV__Detail?*)soap_id_enter(soap,?soap->id,?a,?SOAP_TYPE_SOAP_ENV__Detail,?sizeof(struct?SOAP_ENV__Detail),?0,?NULL,?NULL,?NULL);
            ????
            if?(!a)
            ????????
            return?NULL;
            ????soap_default_SOAP_ENV__Detail(soap,?a);

            ????
            int?service?=?1;
            ????
            int?policy?=?1;

            ????
            if?(soap->body?&&?!*soap->href)
            ????{
            ????????
            for?(;;)
            ????????{????soap
            ->error?=?SOAP_TAG_MISMATCH;
            ????????????
            //if?(soap_flag_fault?&&?soap->error?==?SOAP_TAG_MISMATCH)
            ????????????
            //????if?((a->fault?=?soap_getelement(soap,?&a->__type)))
            ????????????
            //????{????soap_flag_fault?=?0;
            ????????????
            //????????continue;
            ????????????
            //????}
            ????????????
            //if?(soap_flag___any?&&?(soap->error?==?SOAP_TAG_MISMATCH?||?soap->error?==?SOAP_NO_TAG))
            ????????????
            //????if?(soap_inliteral(soap,?"-any",?&a->__any))
            ????????????
            //????{????soap_flag___any--;
            ????????????
            //????????continue;
            ????????????
            //????}
            ????????????
            ????????????
            if?(soap->error?==?SOAP_TAG_MISMATCH)
            ????????????{
            ????????????????
            if(service?==?1)
            ????????????????{
            ????????????????????a
            ->serviceException?=?soap_in_sms2__ServiceException(soap,?"sms2:ServiceException",?a->serviceException,?"");
            ????????????????????
            if(a->serviceException)
            ????????????????????{
            ????????????????????????service?
            =?0;
            ????????????????????????
            continue;
            ????????????????????}
            ????????????????}
            ????????????????
            else?if(policy?==?1)
            ????????????????{
            ????????????????????a
            ->policyException?=?soap_in_sms2__PolicyException(soap,?"sms2:PolicyException",?a->policyException,?"");
            ????????????????????
            if(a->policyException)
            ????????????????????{
            ????????????????????????policy?
            =?0;
            ????????????????????????
            continue;
            ????????????????????}
            ????????????????}
            ????????????????soap
            ->error?=?soap_ignore_element(soap);
            ????????????}
            ????????????
            if?(soap->error?==?SOAP_NO_TAG)
            ????????????????
            break;
            ????????????
            if?(soap->error)
            ????????????????
            return?NULL;
            ????????}
            ????????
            if?(soap_element_end_in(soap,?tag))
            ????????????
            return?NULL;
            ????}
            ????
            else
            ????{????a?
            =?(struct?SOAP_ENV__Detail?*)soap_id_forward(soap,?soap->href,?(void*)a,?0,?SOAP_TYPE_SOAP_ENV__Detail,?0,?sizeof(struct?SOAP_ENV__Detail),?0,?NULL);
            ????????
            if?(soap->body?&&?soap_element_end_in(soap,?tag))
            ????????????
            return?NULL;
            ????}
            ????
            return?a;
            }

            ??? 由此,SOAP接口的主要問題除了“附件”還沒有處理外,就都解決了,其他都是業務應用的問題了,處理起來就有底了~

            posted on 2009-07-27 18:34 codejie 閱讀(1820) 評論(0)  編輯 收藏 引用 所屬分類: C++

            公告

            Using C++

            導航

            統計

            留言簿(73)

            隨筆分類(513)

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            久久99精品久久久久久久不卡| 中文字幕无码久久精品青草| 日韩久久久久久中文人妻 | 狠狠色狠狠色综合久久| 亚洲国产精品成人久久| 精品久久一区二区三区| 亚洲国产精品热久久| 怡红院日本一道日本久久| 久久一区二区免费播放| 亚洲AV无码久久精品蜜桃| 国产精品久久久久久福利漫画| 久久久精品国产Sm最大网站| 久久综合噜噜激激的五月天| 日韩久久无码免费毛片软件| 国产高潮国产高潮久久久| 久久久久久免费视频| 91精品国产91久久久久久| 7777久久久国产精品消防器材| 国产精品嫩草影院久久| 久久国产精品成人影院| 久久性精品| 国产精品日韩深夜福利久久| 色88久久久久高潮综合影院| 欧美麻豆久久久久久中文| 国产精品伊人久久伊人电影| 成人久久精品一区二区三区| 一本色道久久综合狠狠躁| 亚洲欧洲精品成人久久曰影片 | 国产人久久人人人人爽| 久久精品中文字幕一区| 精品无码人妻久久久久久| 国内精品久久久久久野外| 亚洲精品国产字幕久久不卡 | 青青久久精品国产免费看| 青青草原综合久久| 国产精品久久久久久久久| 色偷偷88888欧美精品久久久| 久久久久久国产精品无码下载 | 国产成人久久精品二区三区| 久久国内免费视频| 伊色综合久久之综合久久|