IOS swift XML Web服务post方法返回null

时间:2016-09-16 13:57:40

标签: ios xml soap

我试图通过SWIFT语言在IOS中执行SOAP服务。它返回null不知道我在哪里弄错了,请指导我。

我的出局是

access_token_ : b13a0cfe-1e42-43bf-a625-30c019f611a6

refresh_token:221591ed-1248-4335-bddb-4ead6520ce7b

范围:读写信任

token_type:bearer

exe_url:https://elink.teknorapex.com:3636/xxxxxx/rest/IProcess/Get

Auth_companyId:0000000000000010

Grnd_Acs_access_token_:持票人d5bc126d-5f6b-43ad-ae9c-b2ea7942a03b

< 3c6f6175 74683e3c 6572726f 725f6465 73637269 7074696f 6e3e496e 76616c69 64206163 63657373 20746f6b 656e3a20 64356263 31323664 2d356636 622d3433 61642d61 6539632d 62326561 37393432 61303362 3c2f6572 726f725f 64657363 72697074 696f6e3e 3c657272 6f723e69 6e76616c 69645f74 6f6b656e 3c2f6572 726f723e 3c2f6f61 7574683e>

解析成功!

func get_Search_Process(refresh_token_ : String, mainELinkUrl : String) {



    let exe_url = "\(mainELinkUrl)IProcess/Get"



    let Auth_companyId = defaults.stringForKey("Auth_companyId")!

    let Grnd_Acs_access_token_ = "d5bc126d-5f6b-43ad-ae9c-b2ea7942a03b"//defaults.stringForKey("Grnd_Acs_access_token_")!



print("exe_url : \(exe_url)")

print("Auth_companyId : \(Auth_companyId)")

print("Grnd_Acs_access_token_ : Bearer \(Grnd_Acs_access_token_)")





Alamofire.request(.POST, exe_url,

    parameters: nil,

    encoding: .Custom({

        (convertible, params) in

        let mutableRequest = convertible.URLRequest.copy() as!                NSMutableURLRequest

        mutableRequest.HTTPBody = "<?xml version='1.0' encoding='utf-8'?><Get xmlns='http://tempuri.org/'><reqType>ADR</reqType><prjName></prjName><cusName>Teknor</cusName><folderName>5</folderName><submitterName></submitterName></Get>".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)



        return (mutableRequest, nil)}),

    headers:

    ["CompanyId": "\(Auth_companyId)" ,

        "Marketplace-ApiKey" : "8e77aa8059181079",

        "Authorization": "Bearer \(Grnd_Acs_access_token_)",

        "Accept" :       "text/xml",

        "Content-Type" : "application/xml; charset=UTF-8",

        "Accept-Charset" : "UTF-8",])

    .responsePropertyList { response in 

        //let xml = SWXMLHash.parse(response.data!)

        //print(xml)

        print(response.data!)

        self.parser = NSXMLParser(data: response.data!)



        let success:Bool = self.parser.parse()

        print(self.parser)

        if success {

            print("parse success!")

            print(response.result.value)

            print(self.strXMLData)



        } else {

            print("parse failure!")

        }

}

}



func parser(parser: NSXMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String]) {

    currentElement=elementName;

    /*if(elementName=="Project Name" || elementName=="CustomerName" || elementName=="Submitter Name" || elementName=="Request Number")

    {

        if(elementName=="Project Name"){

            passName=true;

        }

        passData=true;

    }*/

    print(elementName)

}



func parser(parser: NSXMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) {

    /*currentElement="";

    if(elementName=="Project Name" || elementName=="CustomerName" || elementName=="Submitter Name" || elementName=="Request Number")

    {

        if(elementName=="Project Name"){

            passName=false;

        }

        passData=false;

    }*/

    print(elementName)

}



func parser(parser: NSXMLParser, foundCharacters string: String) {

    strXMLData=strXMLData+"\n\n"+string

    print(strXMLData)

    if(passName){

        strXMLData=strXMLData+"\n\n"+string

    }



    if(passData)

    {

        print(string)

    }

    else{

        print("Not Found Char")

    }

}



func parser(parser: NSXMLParser, parseErrorOccurred parseError: NSError) {

    NSLog("failure error: %@", parseError)

    print("failure error: %@", parseError)

}

0 个答案:

没有答案