0
NSURL *url = [NSURL URLWithString:@"http://192.168.1.56/AMSP/AMSPWS.asmx"];

NSString *soapMsg=[NSString stringWithFormat:@"<?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>"
                   "<PostXMLStr xmlns=\"http://tempuri.org/\">"
                   "<cust>%@</cust>"
                   "<tran>%@</tran>"
                   "<ret>%@</ret>"
                   "<ppay>%@</ppay>"
                   "<recp>%@</recp>"
                   "<sCode>%@</sCode>"
                   "<companyShortName>%@</companyShortName>"
                   "<companyCode>%@</companyCode>"
                   "</PostXMLStr>"
                   "</soap:Body>"
                   "</soap:Envelope>",cust,trans,RETURNS,prepayment,receipt,spcode1,companyShortName,companyCode];


NSMutableURLRequest *requests = [NSMutableURLRequest requestWithURL:url
                                                        cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
                                                    timeoutInterval:5];
NSString *msgLength = [NSString stringWithFormat:@"%d",[soapMsg length]];
[requests setHTTPMethod:@"POST"];
[requests addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[requests addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[requests addValue:@"http://tempuri.org/PostXMLStr" forHTTPHeaderField:@"SOAPAction"];

[requests setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding ]];

NSURLResponse *response;
NSError *error = nil;

NSData   *data =[[NSMutableData alloc]init];
data = [NSURLConnection sendSynchronousRequest:requests returningResponse:&response error:&error];

NSString *stringSoap;

stringSoap = [[NSString alloc] initWithData:data encoding:NSMacOSRomanStringEncoding];
NSDictionary *headers = [(NSHTTPURLResponse *)response allHeaderFields];

目的の C を介して WebService を接続するのは初めてです。XML が WebService に接続されていることを確認する方法がわかりません。stringSoap を出力すると、値が得られません。XMLを呼び出すこの正しい方法はわかりません。XML が WebService に接続されているかどうかを確認する方法。どんな助けでも大歓迎です。前もって感謝します。

4

1 に答える 1

0

あなたが新しいので、これはSOAPサービスをObjectiveCに変換するのに役立ちます
sudzc.com
wsdl2objc

于 2013-04-25T09:48:59.287 に答える