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