找不到端点引用(EPR)iphone sdk的服务

时间:2014-03-13 10:19:25

标签: ios iphone objective-c parsing wsdl

在我的应用程序中我使用的是wsdl webservice,但是我收到了这个错误。这里要做的是我的代码:

我不知道为什么我得到这个错误是否有任何/符号更高或我缺少编写代码。还在nslog中打印错误,无法找到端点引用(EPR)的服务。

-(IBAction)buttonClick:(id)sender
{
    recordResults = FALSE;

    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"
    "<CArts_LogIn xmlns=\"http://cpsserver.ppm.ch/\">\n"
    "<username>%@</username>\n"
    "<password>%@</password>\n"
    "</CArts_LogIn>\n"
    "</soap:Body>\n"
    "</soap:Envelope>\n", nameInput.text , psswrd.text
    ];
    NSLog(soapMessage);

    NSURL *url = [NSURL URLWithString:@"http:google.com?wsdl"];
    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://google.com/login" forHTTPHeaderField:@"SOAPAction"];
    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];
    [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

    NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

    if( theConnection )
    {
        webData = [[NSMutableData data] retain];
    }
    else
    {
        NSLog(@"theConnection is NULL");
    }

    [nameInput resignFirstResponder];
    [psswrd resignFirstResponder];
}

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    [webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    NSLog(@"ERROR with theConenction");
    [connection release];
    [webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSLog(@"DONE. Received Bytes: %d", [webData length]);
    NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
    NSLog(theXML);
    [theXML release];

    if( xmlParser )
    {
        [xmlParser release];
    }

    xmlParser = [[NSXMLParser alloc] initWithData: webData];
    [xmlParser setDelegate: self];
    [xmlParser setShouldResolveExternalEntities: YES];
    [xmlParser parse];

    [connection release];
    [webData release];
}

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName
attributes: (NSDictionary *)attributeDict
{
    if( [elementName isEqualToString:@"HelloResult"])
    {
        if(!soapResults)
        {
            soapResults = [[NSMutableString alloc] init];
        }
        recordResults = TRUE;
    }
}
-(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 isEqualToString:@"HelloResult"])
    {
        recordResults = FALSE;
        greeting.text = soapResults;
        [soapResults release];
        soapResults = nil;
    }
}

0 个答案:

没有答案