2013-01-11 23 views
5

私はhtereが "iOSでSOAPを使用する方法"についてウェブ上で利用可能なものが多いと知っていますが、それでもSAOP要求に従うためには失敗しました&レスポンス。ヘルプは非常に感謝しています。私は私がiOS - SOAPリクエストを作成して問題の応答を受け取る方法

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" 
         "<GetMessages xmlns=\"http://tempuri.org/\">\n" 
         "<GroupName>%@</GroupName>\n" 
         "<Date>%@</Date>\n" 
         "</GetMessages>\n" 
         "</soap:Body>\n" 
         "</soap:Envelope>\n" 
         , txtfield1.text 
         , textfield2.text 
         ]; 
NSLog(@"soapMessage: \n%@",soapMessage); 

NSURL *url = [NSURL URLWithString:@"???.asmx"]; 
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://tempuri.org/GetMessages" 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"); 

...シンプルNSURLConnection

POST ???.asmx HTTP/1.1 
Host: ??? 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "http://tempuri.org/GetMessages" 

<?xml version="1.0" encoding="utf-8"?> 
<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/"> 
    <soap:Body> 
    <GetMessages xmlns="http://tempuri.org/"> 
     <GroupName>string</GroupName> 
     <Date>dateTime</Date> 
    </GetMessages> 
    </soap:Body> 
</soap:Envelope> 

要求&応答 SOAPのRequstのためのSOAPレスポンス

HTTP/1.1 200 OK 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 

<?xml version="1.0" encoding="utf-8"?> 
<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/"> 
    <soap:Body> 
    <GetMessagesResponse xmlns="http://tempuri.org/"> 
     <GetMessagesResult>xml</GetMessagesResult> 
    </GetMessagesResponse> 
    </soap:Body> 
</soap:Envelope> 

は、ここで私は要求を送信するために書いたコードが使用 このエラーが発生するconnectionDidFinishLoading

<soap:Fault> 
    <faultcode>soap:Server</faultcode> 
    <faultstring>Server was unable to process request. ---&gt; SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.</faultstring> 
    <detail /> 
    </soap:Fault> 

私は私の質問が要求&を送信する方法であるthis link & used the code in this link & modified according to my convenience to make it worked

呼ば問題はないと思われる懸念応答

事前にどうもありがとう

答えて

2

を受け取りますあなたは01として送信する値にすべての石鹸メッセージの送信/ recvに関連して- 正しい形式ではありません。

=>サーバーが要求を処理できませんでした。 --- > SqlDateTimeがオーバーフローします。 1/1/1753 12:00:00 AMと12/31/9999 11:59:59 PMの間である必要があります。

使用NSDateFormatterは、要求された形式

+0

ちょっとで日付文字列を書き込みます。ありがとうございました..日付と時刻を書式設定した後、完璧に機能しました –

関連する問題