Arif YILMAZ
Arif YILMAZ

Reputation: 5866

getting an error on xml soap response

I am getting an error when I send a request to webservice soap with iphone. How can I fix it?

here is the message I am getting.

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
  <soap:Fault>
     <faultcode>soap:Client</faultcode>
     <faultstring>Server did not recognize the value of HTTP Header SOAPAction: HelloWorld.</faultstring>
      <detail />
   </soap:Fault>
 </soap:Body>
 </soap:Envelope>

here is my objective-c code

-(IBAction)buttonClick:(id)sender
{
recordResults = FALSE;

NSString *soapMsg =
[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"
 "<HelloWorld xmlns=\"http://tempuri.org/\" />\n"
 "</soap:Body>\n"
 "</soap:Envelope>\n"];

//---print it to the Debugger Console for verification---
NSLog(soapMsg);

NSURL *url = [NSURL URLWithString: @"http://servicing2.rotanet.com.tr/service1.asmx"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self];

//---set the various headers---
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:@"HelloWorld" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];

//---set the HTTP method and body---
[req setHTTPMethod:@"POST"];
[req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];


theConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (theConnection) {
    webData = [[NSMutableData data] retain];
}
}

I have been working on this for 2 days. and I am going crazy. Do you guys have any suggestion?

Upvotes: 1

Views: 1099

Answers (3)

Gajendrasinh Chauhan
Gajendrasinh Chauhan

Reputation: 3397

Replace this,

[req addValue: @"http://tempuri.org/HelloWorld [req addValue:@"HelloWorld" forHTTPHeaderField:@"SOAPAction"];" forHTTPHeaderField:@"SOAPAction"];

instead of

[req addValue:@"HelloWorld" forHTTPHeaderField:@"SOAPAction"];

Upvotes: 1

CRDave
CRDave

Reputation: 9285

I think you have passed wrong SOAPAction

Try this

[req addValue:@"http://tempuri.org/HelloWorld" forHTTPHeaderField:@"SOAPAction"]

Upvotes: 0

gaige
gaige

Reputation: 17481

The server is unable to locate the service corresponding to the request that you are sending. The SOAP transaction you've created sends:

"<HelloWorld xmlns=\"http://tempuri.org/\" />\n"

Which the client expects the server to understand. In this case, your server does not understand the transaction request and is returning:

  Server did not recognize the value of HTTP Header SOAPAction: HelloWorld.

It appears that your SOAP client is just fine, except that the action HelloWorld doesn't correspond to anything on the server.

Check the server and make sure that's a valid action, and correct either the client to send a valid action request, or the server to respond to the request you're sending.

Upvotes: 0

Related Questions