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

            Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere

            路漫漫,長(zhǎng)修遠(yuǎn),我們不能沒(méi)有錢
            隨筆 - 173, 文章 - 0, 評(píng)論 - 257, 引用 - 0
            數(shù)據(jù)加載中……

            IOS WSDL2OBJC如何與CXF對(duì)接

            首先, WSDL2OBJC直接生成的代碼是無(wú)法正確發(fā)送CXF能解析的數(shù)據(jù)包的

            我懶得去看WSDL2OBJC的源碼, 但是由其生成的源碼看看倒是ok的

            我wsdl的服務(wù)名是HotelPortService
            生成的文件中有個(gè)HotelPortServiceSvc.m, 要修改的地方全部集中在這個(gè)文件
            首先, 找到如下代碼的位置, 替換掉

            - (NSString *)serializedFormUsingHeaderElements:(NSDictionary *)headerElements bodyElements:(NSDictionary *)bodyElements

            {

                xmlDocPtr doc;

            doc = xmlNewDoc((const xmlChar*)XML_DEFAULT_VERSION);

            if (doc == NULL) {

            NSLog(@"Error creating the xml document tree");

            return @"";

            }

            xmlNodePtr root = xmlNewDocNode(doc, NULL, (const xmlChar*)"Envelope", NULL);

            xmlDocSetRootElement(doc, root);

            xmlNsPtr soapEnvelopeNs = xmlNewNs(root, (const xmlChar*)"http://schemas.xmlsoap.org/soap/envelope/", (const xmlChar*)"soap");

            xmlSetNs(root, soapEnvelopeNs);

            xmlNsPtr xslNs = xmlNewNs(root, (const xmlChar*)"http://www.w3.org/1999/XSL/Transform", (const xmlChar*)"xsl");

            xmlNewNs(root, (const xmlChar*)"http://www.w3.org/2001/XMLSchema-instance", (const xmlChar*)"xsi");

            xmlNewNsProp(root, xslNs, (const xmlChar*)"version", (const xmlChar*)"1.0");

            xmlNewNs(root, (const xmlChar*)"http://www.w3.org/2001/XMLSchema", (const xmlChar*)"xs");

            xmlNewNs(root, (const xmlChar*)"http://port.ekezhan.com/", (const xmlChar*)"HotelPortServiceSvc");//字符串部分根據(jù)服務(wù)名不同而不同

            if((headerElements != nil) && ([headerElements count] > 0)) {

            xmlNodePtr headerNode = xmlNewDocNode(doc, soapEnvelopeNs, (const xmlChar*)"Header", NULL);

            xmlAddChild(root, headerNode);

            for(NSString *key in [headerElements allKeys]) {

            id header = [headerElements objectForKey:key];

            xmlAddChild(headerNode, [header xmlNodeForDoc:doc elementName:key elementNSPrefix:nil]);

            }

            }

            if((bodyElements != nil) && ([bodyElements count] > 0)) {

            xmlNodePtr bodyNode = xmlNewDocNode(doc, soapEnvelopeNs, (const xmlChar*)"Body", NULL);

            xmlAddChild(root, bodyNode);

            for(NSString *key in [bodyElements allKeys]) {

            id body = [bodyElements objectForKey:key];

            xmlAddChild(bodyNode, [body xmlNodeForDoc:doc elementName:key elementNSPrefix:nil]);

            }

            }

            xmlChar *buf;

            int size;

            xmlDocDumpFormatMemory(doc, &buf, &size, 1);

            NSString *serializedForm = [NSString stringWithCString:(const char*)buf encoding:NSUTF8StringEncoding];

            xmlFree(buf);

            xmlFreeDoc(doc);

            return serializedForm;

            }


            替換成:

            - (NSString *)serializedFormUsingHeaderElements:(NSDictionary *)headerElements bodyElements:(NSDictionary *)bodyElements

            {

                xmlDocPtr doc;

            doc = xmlNewDoc((const xmlChar*)XML_DEFAULT_VERSION);

            if (doc == NULL) {

            NSLog(@"Error creating the xml document tree");

            return @"";

            }

            xmlNodePtr root = xmlNewDocNode(doc, NULL, (const xmlChar*)"Envelope", NULL);

            xmlDocSetRootElement(doc, root);

            xmlNsPtr soapEnvelopeNs = xmlNewNs(root, (const xmlChar*)"http://schemas.xmlsoap.org/soap/envelope/", (const xmlChar*)"soapenv");//此處修改

            xmlSetNs(root, soapEnvelopeNs);

            //xmlNsPtr xslNs = xmlNewNs(root, (const xmlChar*)"http://www.w3.org/1999/XSL/Transform", (const xmlChar*)"xsl");

            //xmlNewNs(root, (const xmlChar*)"http://www.w3.org/2001/XMLSchema-instance", (const xmlChar*)"xsi");

            //xmlNewNsProp(root, xslNs, (const xmlChar*)"version", (const xmlChar*)"1.0");

            //xmlNewNs(root, (const xmlChar*)"http://www.w3.org/2001/XMLSchema", (const xmlChar*)"xs");

                

            xmlNewNs(root, (const xmlChar*)"http://port.ekezhan.com/", (const xmlChar*)"port");

            if((headerElements != nil) && ([headerElements count] > 0)) {

            xmlNodePtr headerNode = xmlNewDocNode(doc, soapEnvelopeNs, (const xmlChar*)"Header", NULL);

            xmlAddChild(root, headerNode);

            for(NSString *key in [headerElements allKeys]) {

            id header = [headerElements objectForKey:key];

            xmlAddChild(headerNode, [header xmlNodeForDoc:doc elementName:key elementNSPrefix:nil]);

            }

            }

            //此處修改

            else

            {  

            xmlNodePtr headerNode = xmlNewDocNode(doc, soapEnvelopeNs, (const xmlChar*)"Header", NULL);

            xmlAddChild(root, headerNode);

            }

            if((bodyElements != nil) && ([bodyElements count] > 0)) {

            xmlNodePtr bodyNode = xmlNewDocNode(doc, soapEnvelopeNs, (const xmlChar*)"Body", NULL);

            xmlAddChild(root, bodyNode);

            for(NSString *key in [bodyElements allKeys]) {

            id body = [bodyElements objectForKey:key];

            xmlAddChild(bodyNode, [body xmlNodeForDoc:doc elementName:key elementNSPrefix:@"port"]);//此處修改

            }

            }

            xmlChar *buf;

            int size;

            xmlDocDumpFormatMemory(doc, &buf, &size, 1);

            NSString *serializedForm = [NSString stringWithCString:(const char*)buf encoding:NSUTF8StringEncoding];

            xmlFree(buf);

            xmlFreeDoc(doc);

            return serializedForm;

            }


            替換全部

            elementNSPrefix:@"HotelPortServiceSvc" 

            elementNSPrefix:nil  //字符串部分根據(jù)服務(wù)名不同而不同



            替換全部

            nodeName = [NSString stringWithFormat:@"%@:%@", @"HotelPortServiceSvc", elName];//字符串部分根據(jù)服務(wù)名不同而不同

             

            nodeName = [NSString stringWithFormat:@"%@", elName];




            然后再編譯運(yùn)行. 如果沒(méi)有意外, 就能獲得正確的結(jié)果了. 文檔如有錯(cuò)漏, 歡迎指正補(bǔ)全



            測(cè)試環(huán)境 

            Mac OS 10.6.8,  xcode 4.0.1,  WSDL2ObjC 0.7 pre1

            posted on 2011-11-04 17:36 Khan 閱讀(1768) 評(píng)論(2)  編輯 收藏 引用 所屬分類: 跨平臺(tái)開(kāi)發(fā)

            評(píng)論

            # re: IOS WSDL2OBJC如何與CXF對(duì)接  回復(fù)  更多評(píng)論   

            比較討厭d地方是, 每次發(fā)布的webservice變動(dòng). 都需要重復(fù)一次, 不過(guò)仍舊比人肉解析xml要省事兒
            2011-11-04 17:41 | Khan's Notebook

            # re: IOS WSDL2OBJC如何與CXF對(duì)接  回復(fù)  更多評(píng)論   

            我只想說(shuō)太給力了。。解決了我一周都沒(méi)有解決的問(wèn)題,webservice交互問(wèn)題,忙了一周多都沒(méi)忙出來(lái)。。給力
            2014-09-11 14:59 | 左凌風(fēng)
            色综合久久久久网| 国产精品久久婷婷六月丁香| 久久久亚洲精品蜜桃臀| 精品久久一区二区三区| 97超级碰碰碰碰久久久久| 久久国产精品波多野结衣AV| 久久中文字幕视频、最近更新 | 久久久久久久女国产乱让韩| 亚洲国产另类久久久精品小说| 99久久婷婷免费国产综合精品| 久久综合九色欧美综合狠狠| 久久无码AV一区二区三区| 精品国产VA久久久久久久冰| 日韩十八禁一区二区久久| 久久狠狠色狠狠色综合| 欧美国产精品久久高清| 久久精品国产福利国产琪琪| 久久青青草视频| 久久亚洲高清观看| 久久996热精品xxxx| 久久无码人妻一区二区三区午夜| 久久午夜福利电影| 国产精品18久久久久久vr| 久久久久99这里有精品10| 国产精品久久波多野结衣| 日产精品久久久久久久| 国产2021久久精品| 国产成人精品久久| 日产精品99久久久久久| 久久综合亚洲色HEZYO国产| 77777亚洲午夜久久多喷| 久久久久国产精品人妻| 国产精品热久久无码av| 久久夜色精品国产噜噜亚洲AV| 日本加勒比久久精品| 精品久久国产一区二区三区香蕉| 久久99国产乱子伦精品免费| 久久精品卫校国产小美女| 亚洲欧美一级久久精品| 久久伊人五月丁香狠狠色| 伊人久久大香线蕉精品不卡|