开发者

Problem with web services in iphone app

I am trying to connect to a web service for my iphone app (never imagined it was going to be this hard....) but I am getting the following error: Can't serve media types listed in the Accept header, No resource method found for POST, return 405 with Allow header.

The full response is the following: CLIENT.MethodNotAllowedCan't serve media types listed in the Accept header, No resource method found for POST, return 405 with Allow header.

Any ideas of what this means? I don't know where to start and tried multiple开发者_运维知识库 different things. Here is the code I am using:

   NSString *soapMsg = 
    [NSString stringWithFormat:
     @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
     "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"
     "<soap:Body>"
     "<standardization inputFormat=\"docdb\" outputFormat=\"epodoc\" xmlns=\"http://abc.mycompany.org\">"
     "<input>"
     "<publication xmlns=\"http://www.mycompany.org/exchange\">"
     "<document-id><country>MD</country>"
     "<number>20050130</number>"
     "<mytype>A</mytype>"
     "<date>20050130</date>"
     "</document-id></publication></input></standardization></soap:Body></soap:Envelope>"];

    NSLog(@"%@", soapMsg);

    NSURL *url = [NSURL URLWithString:
                  @"http://abc.mycompany.org/2.6.2/rest-services/myservice"];
    NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];

    //set various headers
    NSString *msgLength = [NSString stringWithFormat:@"%d",
                           [soapMsg length]];
    [req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];

    [req addValue:msgLength forHTTPHeaderField:@"Content-Length"];

    //set http methods and body
    [req setHTTPMethod:@"POST"];
    [req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];

    conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];

    if (conn) {
        webData = [[NSMutableData data] retain];
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜