2012-03-07 4 views
0

を使用してSOAPメッセージとURLを叩く:Objective Cのは:これは私のコードでPOSTメソッド

NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]]; 
NSURL *url = [NSURL URLWithString:urlString]; 
theRequest = [NSMutableURLRequest requestWithURL:url]; 
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; 

[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; 
[theRequest addValue:@"gzip" forHTTPHeaderField:@"accept-encoding"]; 
[theRequest addValue:@"en-us" forHTTPHeaderField:@"accept-language"]; 
[theRequest addValue:@"[application/soap+xml, application/dime, multipart/related, text/*]" forHTTPHeaderField:@"Accept"]; 
//[theRequest addValue:@"user_agent" forHTTPHeaderField:@"user-agent"]; 
[theRequest setHTTPMethod:@"POST"]; 
[theRequest setHTTPBody: [requestMessage dataUsingEncoding:NSUTF8StringEncoding]]; 
NSLog(@"REQUEST\n%@", theRequest); 
webConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; 

そしてconnectionDidFinishLoadingで、私はこの1つを書いた:

NSString *theXML = [[NSString alloc] initWithBytes: [dataFromWebService mutableBytes] length:[dataFromWebService length] encoding:NSUTF8StringEncoding]; 
NSLog(@"XML:\n%@", theXML); 

、私は、コードを実行すると、

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Error reading XMLStreamReader.</faultstring></soap:Fault></soap:Body></soap:Envelope> 

なぜこのエラーは発生していますが、実際の応答はありません。アプリ側またはサーバー側でエラーですか?

編集:私は、SOAPメッセージ '要求メッセージ' としてペイロード部分を渡しています

Content-Type: text/xml; charset=utf-8 
Headers: {Accept=[application/soap+xml, application/dime, multipart/related, text/*], cache-control=[no-cache], Content-Length=[407], content-type=[text/xml; charset=utf-8], host=[172.16.253.74:8080], pragma=[no-cache], SOAPAction=["urn:Login"], user-agent=[Axis/1.4]} 
Payload: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><login xmlns="http://tilloperations.services.mpos.tcs.com/"><arg0 xmlns=""><password>[email protected]</password><userId>posadmin</userId></arg0></login></soapenv:Body></soapenv:Envelope> 

:これは、SOAPメッセージです。

+0

あなたのsoapMessageを見せてください – Hector

+0

編集をご覧ください。 – utsabiem

+0

あなたのxmlnsのURLを確認してください – Hector

答えて

0

私はこれが古い質問であることを認識していますが、この問題はほぼ確実にarg0要素の空白のデフォルト名前空間宣言です。 Namespaces in XML仕様のセクション2.2から引用

「は、それが合法的URI参照ですが、空の文字列は、名前空間名として 使用することはできません。」

関連する問題