[IPhone-app] mobile phone home location query Software

Source: Internet
Author: User

Bored. I wrote a few apps over the weekend and finally finished the network in the morning. I often access the Internet on Mac with a 8139 Nic of 5 yuan.

 

Simple icons...

 

 

Technical points:

 

1. Group A soap package. Use nlurlconnection to connect.

 

2. Find a WebService.Http://webservice.webxml.com.cn

 

3. Parse XML.

 

4. Display and drag controls.

 

The Code sent by the SOAP header in the casual vertex group

Nsstring * Soapmessage = [Nsstring stringwithformat:
@" <? XML version = \ " 1.0 \ " Encoding = \ " UTF - 8 \ " ?> \ N "
" <Soap: envelope xmlns: xsi = \ " HTTP: // Www.w3.org/2001/xmlschema-instance\ "xmlns: XSD = \" Http://www.w3.org/2001/XMLSchema \ "Xmlns: Soap = \" Http://schemas.xmlsoap.org/soap/envelope/ \ "> \ N"
" <Soap: Body> \ n "
" <Getmobilecodeinfo xmlns = \ " HTTP: // Webxml.com.cn/\ "> \ n"
" <Mobilecode >%@ </mobilecode> \ n "
" <Userid> </userid> \ n "
" </Getmobilecodeinfo> \ n "
" </Soap: Body> \ n "
" </Soap: envelope> \ n " , Nameinput. Text
];
Nslog (soapmessage );

Nsurl * URL = [Nsurl urlwithstring: @" Http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx " ];
Nsmutableurlrequest * Therequest = [Nsmutableurlrequest requestwithurl: url];
Nsstring * Msglength = [Nsstring stringwithformat: @" % D " , [Soapmessage length];

[Therequest addvalue: @" Text/XML; charset = UTF-8 " Forhttpheaderfield: @" Content-Type " ];
[Therequest addvalue: @" Http://WebXml.com.cn/getMobileCodeInfo " Forhttpheaderfield: @" Soapaction " ];
[Therequest addvalue: msglength forhttpheaderfield: @" Content-Length " ];
[Therequest sethttpmethod: @" Post " ];
[Therequest sethttpbody: [soapmessage datausingencoding: nsutf8stringencoding];

Nsurlconnection * THECONNECTION = [[Nsurlconnection alloc] initwithrequest: therequest Delegate : Self];

 

 

 

 

 

 

 

For XML parsing, nsxmlparse is used. Okay. Ink.

 

 -(Void) Parser :( nsxmlparser*) Parser didstartelement :( nsstring*) Elementname namespaceuri :( nsstring*) Namespaceuri qualifiedname :( nsstring*) QNAME

Attributes: (nsdictionary * ) Attributedict
{
If ([Elementname isinclutostring: @" Getmobilecodeinforesult " ])
{
If ( ! Soapresults)
{
Soapresults = [[Nsmutablestring alloc] init];
}
}
}
- ( Void ) Parser :( nsxmlparser * ) Parser foundcharacters :( nsstring * ) String
{
If (Recordresults)
{
[Soapresults appendstring: String ];
}
}
- ( Void ) Parser :( nsxmlparser * ) Parser didendelement :( nsstring * ) Elementname namespaceuri :( nsstring * ) Namespaceuri qualifiedname :( nsstring * ) QNAME
{
If ([Elementname isinclutostring: @" Getmobilecodeinforesult " ])
{
Resultoutput. Text = Soapresults;
[Soapresults release];
Soapresults = Nil;
}
}

 

To prevent leeching, mark the text

Http://alexliu.cnblogs.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.