简体   繁体   中英

call wcf service from xcode4.3

I am a .Net programmer and a beginner in Xcode. I want to display the result from a WCF service on the iPad in UITableViewController. I have successfully created stubs for the service by using wsdl2objc. The SOAP message created is as follows:

2012-07-25 14:02:37.169 TestWCF[5280:fb03] OutputHeaders:
{
  "Content-Length" = 572;
  "Content-Type" = "text/xml; charset=utf-8";
  Host = "XXX.XXX.XXX";
  SOAPAction = "http://tempuri.org/IDocSync/getAllCategories";
  "User-Agent" = wsdl2objc;
}
2012-07-25 14:02:37.172 TestWCF[5280:fb03] OutputBody:
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/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:iPadDocSyncServiceSvc="http://tempuri.org/" xmlns:ns1="http://tempuri.org/Imports" xmlns:tns1="http://schemas.datacontract.org/2004/07/DocSyncService"   xmlns:tns2="http://schemas.microsoft.com/2003/10/Serialization/" xsl:version="1.0">
<soap:Body>
<iPadDocSyncServiceSvc:getAllCategories/>
</soap:Body>
</soap:Envelope>
2012-07-25 14:03:03.119 TestWCF[5280:fb03] ResponseStatus: 200
2012-07-25 14:03:03.120 TestWCF[5280:fb03] ResponseHeaders:
{
  "Cache-Control" = private;
  "Content-Encoding" = gzip;
 "Content-Length" = 421;
 "Content-Type" = "text/xml; charset=utf-8";
  Date = "Wed, 25 Jul 2012 06:03:02 GMT";
 Server = "Microsoft-IIS/7.5";
 "Set-Cookie" = "ASP.NET_SessionId=55w4noiub50zqtqclwdx3ral; path=/; HttpOnly";
  Vary = "Accept-Encoding";
  "X-AspNet-Version" = "4.0.30319";
  "X-Powered-By" = "ASP.NET";
}
2012-07-25 14:03:03.121 TestWCF[5280:fb03] ResponseBody:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
    <getAllCategoriesResponse xmlns="http://tempuri.org/">
        <getAllCategoriesResult        xmlns:a="http://schemas.datacontract.org/2004/07/DocSyncService"    xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <a:Category>
                    <a:categoryId>4</a:categoryId>
                    <a:categoryName>IT</a:categoryName>
                    <a:categoryType>0</a:categoryType>
                    <a:docCount>3</a:docCount>
                    <a:subCategoryId>0</a:subCategoryId>
                </a:Category>
                <a:Category>
                    <a:categoryId>6</a:categoryId>
                    <a:categoryName>CPG</a:categoryName>
                    <a:categoryType>0</a:categoryType>
                    <a:docCount>1</a:docCount>
                    <a:subCategoryId>0</a:subCategoryId>
                </a:Category>
        </getAllCategoriesResult>
    </getAllCategoriesResponse>
</s:Body>
</s:Envelope>

The code in Appdelegate.m is:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
   BasicHttpBinding_IDocSyncBinding *myBinding = [iPadDocSyncServiceSvc    BasicHttpBinding_IDocSyncBinding];
myBinding.logXMLInOut = YES;

//iPadDocSyncServiceSvc_getAllCategories *allCate =     [[iPadDocSyncServiceSvc_getAllCategories new]autorelease];
iPadDocSyncServiceSvc_getAllCategories *allCate = [[iPadDocSyncServiceSvc_getAllCategories     alloc]init];

BasicHttpBinding_IDocSyncBindingResponse *response = [myBinding getAllCategoriesUsingParameters:allCate];

for(id bodyPart in response.bodyParts)
{
    //if([bodyPart isKindOfClass:[BasicHttpBinding_IDocSyncBindingResponse class]])
    //{
    //tns1_ArrayOfCategory *cateClass = (tns1_ArrayOfCategory *) bodyPart;
    //[self.tableView reloadData];

    //categories  = (NSMutableArray *) cateClass;
    //tns1_ArrayOfCategory *cateClass = [bodyPart getAllCategoriesResult];

    self.categories = (NSMutableArray *) [bodyPart getAllCategoriesResult];
    //}
}


return YES;
}

When I run this,nothing is displayed in the Simulator...it shows a blank screen. There is something very obvious that I am missing. How can I get it working?

I wrote a few tutorials using Wsdl2Objc a while back; maybe they can help.

http://brismith66.blogspot.com/search/label/iPhone%20Development

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM