2013-01-11 14 views
5

मुझे पता है कि "आईओएस में एसओएपी का उपयोग कैसे करें" के लिए वेब पर बहुत सारी चीज़ें उपलब्ध हैं, लेकिन फिर भी मैं SAOP अनुरोध & प्रतिक्रिया के बाद करने में विफल रहा। सहायता बहुत सराहना की है। मैं सरल NSURLConnection का उपयोग अनुरोध & प्रतिक्रिया सोप requstआईओएस - एसओएपी अनुरोध कैसे करें और चिंता प्रतिक्रिया प्राप्त करें

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> 

सोप प्रतिक्रिया

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> 

यहाँ के लिए कोड मैं अनुरोध भेजने के लिए लिखा है ..

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"); 

मैं कर रहा हूँ इस त्रुटि को connectionDidFinishLoading

0 में प्राप्त करना
<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 के रूप में भेजते हैं- इसमें सही प्रारूप नहीं है।

=> सर्वर अनुरोध संसाधित करने में असमर्थ था। --- > एसक्लडेट टाइम ओवरफ्लो। 1/1/1753 12:00:00 पूर्वाह्न और 12/31/9999 11:59:59 अपराह्न के बीच होना चाहिए।

उपयोग एक NSDateFormatter अनुरोध किया प्रारूप

+0

अरे में दिनांक स्ट्रिंग लिखने के लिए। बहुत बहुत धन्यवाद .. यह दिनांक और समय स्वरूपण के बाद सही काम करता है –

संबंधित मुद्दे