0
我發送一個xml肥皂請求登錄到我的crm ondemand網站,但我得到一個錯誤「http請求不包含格式良好的xml。試圖解析它產生一個以下錯誤的東西XML-20108(致命錯誤)根元素缺失的開始「。我不知道該做什麼:S ...我已經浪費了我2天的時間n無法取得任何進展..請幫助我解決這個問題!:(..肥皂請求中有錯誤的地方XML Soap請求crm ondemand從目標c
NSString *post = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> \
< soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/ \" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:ns9060=\"http://tempuri.org\"> \
< soap:Header> \
< wsse:Security soap:mustUnderstand=\"1\"> \
< wsse:UsernameToken> \
< wsse:Username>MyUserName</wsse:Username> \
< wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText\">MyPassword</wsse:Password> \
< /wsse:UsernameToken> \
< /wsse:Security> \
< /soap:Header> \
< soap:Body> \
< AccountQueryPage_Input xmlns=\"urn:crmondemand/ws/ecbs/account/10/2004\"> \
< ListOfAccount xmlns=\"urn:/crmondemand/xml/Account/Query\"> \
< Account> \
< AccountName/> \
< /Account> \
< /ListOfAccount> \
< /AccountQueryPage_Input> \
< /soap:Body> \
< /soap:Envelope>"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSURL *url = [NSURL URLWithString:@"https://secure-ausomxdsa.crmondemand.com/Services/Integration"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPMethod:@"POST"];
[theRequest setValue:@"document/urn:crmondemand/ws/ecbs/account/10/2004:AccountQueryPage" forHTTPHeaderField:@"SOAPAction"];
[theRequest setValue:@"application/soap+xml;charset=ISO-8859-1" forHTTPHeaderField:@"Current-Type"];
[theRequest setValue:postLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPBody:postData];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection)
{
status.text = @"Connection";
webData = [[NSMutableData data] retain];
}
else
{
}
}
- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
status.text = @"didReceiveResponse";
[webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
status.text = @"didReceiveData";
[webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
status.text = @"didFailWithError";
[connection release];
[webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *loginStatus = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
status.text = nil;
status.text = loginStatus;
[loginStatus release];
[connection release];
[webData release];
}
@end
老兄,請幫個忙,使用ASIHTTPRequest:http://www.google.com.au/url?sa=t&source=web&cd=1&ved=0CBgQFjAA&url=http%3A%2F%2Fallseeing-i.com%2FASIHTTPRequest %2F&ei = 2-VHTa_jLMmXcdSx5OIC&usg = AFQjCNFpUZprrMAY9mTk0aGzEzwSG8L9sg – 2011-02-01 10:52:18
夥計......你能告訴我在我的代碼中出了什麼問題嗎?im新客戶cn浪費了2,3天的時間對我來說一個非常新的方法對我來說不是一件好事:S :( – Casper 2011-02-01 11:37:40