如何在反应原生中消费肥皂服务?

Rak*_*esh 7 xmlhttprequest reactjs react-native

我是新的反应本地人,想要消费肥皂服务,但没有得到任何api这样做.我用json解析器使用了fetch api for Rest服务.是否有任何api可用于使用soap服务并在react-native中解析xml.在ios中我们创建肥皂信封并发送到服务器,如:

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/XMLSchem\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
                         "<soap:Body>\n"
                         "<GetCitiesByCountry xmlns=\"http://www.webserviceX.NET\">\n"
                         "<CountryName>%@</CountryName>\n"
                         "</GetCitiesByCountry>\n"
                         "</soap:Body>\n"
                         "</soap:Envelope>\n",@"India"];

NSURL *url = [NSURL URLWithString:@"http://webservicex.com/globalweather.asmx"];

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];

[theRequest addValue: @"http://www.webserviceX.NET/GetCitiesByCountry"
  forHTTPHeaderField:@"SOAPAction"];

[theRequest addValue: [NSString stringWithFormat:@"%lu",(unsigned long)[soapMessage length]]
  forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

self.responseData = [[NSMutableData alloc]init];

NSURLSession *soapSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:[NSOperationQueue mainQueue]];

NSURLSessionDataTask *dataTask = [soapSession dataTaskWithRequest:theRequest];

[dataTask resume];
Run Code Online (Sandbox Code Playgroud)

同样我正在寻找反应原生的东西.