首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

应用wsdl2objc实现Soap

2012-12-28 
使用wsdl2objc实现Soapwsdl2objc是一个开源库,根据wsdl将web service转化成objc的接口和数据结构。?调用示

使用wsdl2objc实现Soap

wsdl2objc是一个开源库,根据wsdl将web service转化成objc的接口和数据结构。

?

调用示例:

?

- (IBAction)buttonPressed:(id)sender {LocalTimeSoapBinding *binding = [[LocalTime LocalTimeSoapBinding] initWithAddress:@"http://www.ripedevelopment.com/webservices/LocalTime.asmx"];binding.logXMLInOut = YES;  // to get logging to the console.LocalTime_LocalTimeByZipCode *request = [[LocalTime_LocalTimeByZipCode alloc] init];request.ZipCode = @"29687"; // insert your zip code here.LocalTimeSoapBindingResponse *resp = [binding LocalTimeByZipCodeUsingParameters:request];for (id mine in resp.bodyParts) {if ([mine isKindOfClass:[LocalTime_LocalTimeByZipCodeResponse class]]) {field.text = [mine LocalTimeByZipCodeResult];}}    [request release];}

?

控制台输出:

?

OutputHeaders:{    "Content-Length" = 466;    "Content-Type" = "text/xml; charset=utf-8";    Host = "www.ripedevelopment.com";    SOAPAction = "http://www.ripedev.com/LocalTimeByZipCode";    "User-Agent" = wsdl2objc;}OutputBody:<?xml version="1.0"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:LocalTime="http://www.ripedev.com/" xsl:version="1.0">  <soap:Body>    <LocalTime:LocalTimeByZipCode>      <LocalTime:ZipCode>29687</LocalTime:ZipCode>    </LocalTime:LocalTimeByZipCode>  </soap:Body></soap:Envelope>ResponseStatus: 200ResponseHeaders:{    "Cache-Control" = private;    Connection = close;    "Content-Encoding" = gzip;    "Content-Length" = 233;    "Content-Type" = "text/xml; charset=utf-8";    Date = "Sat, 21 Jul 2012 06:52:05 GMT";    Expires = "Sat, 21 Jul 2012 06:52:35 GMT";    Server = "Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8e-fips-rhel5 mod_mono/2.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_jk/1.2.28 mod_perl/2.0.4 Perl/v5.8.8";    Vary = "Accept-Encoding,User-Agent";    "X-AspNet-Version" = "2.0.50727";}ResponseBody:<?xml version="1.0" encoding="utf-8"?><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/"><soap:Body><LocalTimeByZipCodeResponse xmlns="http://www.ripedev.com/"><LocalTimeByZipCodeResult>7/21/2012 2:52:05 AM</LocalTimeByZipCodeResult></LocalTimeByZipCodeResponse></soap:Body></soap:Envelope>

热点排行