SOAP web service call with parameters is failing

I have a very simple .net web service which accepts a string parameter and returns the same string converted to uppercase.

The web service works just fine when called from an ASP.NET web page.

However, when I call it from an IOS app the parameter sent in is not received, even though I have verified that the values are sent in the SOAP message as can be seen below:

<soap12:Body>
<TestReturnVal xmlns="http://tempuri.org/" /><pName>brian</pName>
</soap12:Body>

Open in new window


The .NET function that's being called is:
<WebMethod()>_
Public Function TestReturnVal (ByVal pName As String) As String

Dim nUpper As String = UCase(pName)
Return "RETURN TEXT: " & nUpper & ": SHOULD BE HERE"

End Function

Open in new window


When I get the returned stream from the above function, I only get the hard-coded text and not the value of the variable.

<TestReturnValResult>RETURN TEXT: : SHOULD BE HERE</TestReturnValResult>

Open in new window


Any help would be extremely helpful, I'm completely stumped on this :(
BrianFordAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
I have very little experience with iOS, but I would look for an HTTP debugger, so that you can see the difference between the web application and the iOS application.

Quick search:

PonyDebugger: Remote Debugging Tools for Native iOS Apps
http://corner.squareup.com/2012/08/ponydebugger-remote-debugging.html
0
BrianFordAuthor Commented:
Thanks I'll take a look at that, the strange thing is that if I call a web service that does not expect any parameter (just returns a string for example) everything works perfectly :(
0
Bob LearnedCommented:
How did you generate this SOAP message?

<soap12:Body>
     <TestReturnVal xmlns="http://tempuri.org/" /><pName>brian</pName>
</soap12:Body>
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

BrianFordAuthor Commented:
The above is just a snip of the complete message, but it is taken from the service definition (WSDL) and is basically hard-coded in the app.

The complete iOS code for the request is below:

NSString *soapMsg = [NSString stringWithFormat:
                         @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
                         "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">"
                         "<soap12:Body>"
                         "<TestReturnVal xmlns=\"http://tempuri.org/\" />"
                         "<pName>%@</pName>"
                         "</soap12:Body>"
                         "</soap12:Envelope>", @"brian"];

Open in new window

0
Bob LearnedCommented:
Another approach would be to use Soap UI to debug the SOAP messages from the web application where it works, so that you can make sure that you have the messages exactly as required.

‘’SoapUI free tool to help debug the Web Services’’
soapUI-in-the-news/soapui-free-tool-for-to-help-debug-the-web-services.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BrianFordAuthor Commented:
I'll take a look at that also, but I know the message is in the correct format as it's taken directly from the WebService definition which is shown below:

The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.

POST /tagScan.asmx HTTP/1.1
Host: <snip>
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/webservices/checkGP"

<?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>
    <checkGP xmlns="http://tempuri.org/webservices">
      <tagNum>string</tagNum>
      <qty>string</qty>
    </checkGP>
  </soap:Body>
</soap:Envelope>
0
Bob LearnedCommented:
What are you using on the iOS side to send the SOAP message?
0
BrianFordAuthor Commented:
It's basically just an HTTP Request
0
Bob LearnedCommented:
No, I meant what are you using to develop the software (design platform, version, ...)?
0
BrianFordAuthor Commented:
oh sorry, I'm using XCode V5.0.2 on a Mac
0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
but I know the message is in the correct format as it's taken directly from the WebService definition which is shown below
Did you not post what you meant on your previous comment http:#a39711717 ? What you have posted appears to be some totally different to the other snippets/code that you have posted, as it deals with the "checkGP" service with parameters of "tagNum" and "qty", whereas your question is about "TestRuternVal" and "pName".


In any case, I'm 99% sure that your message is NOT in the correct format. Try the below code in your iOS app...
NSString *soapMsg = [NSString stringWithFormat:
                         @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
                         "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">"
                         "<soap12:Body>"
                         "<TestReturnVal xmlns=\"http://tempuri.org/\">"
                         "<pName>%@</pName>"
                         "</TestReturnVal>"
                         "</soap12:Body>"
                         "</soap12:Envelope>", @"brian"];

Open in new window

The change that I have made, is that now the "pName" element is actually a child of the "TestReturnVal" element. The way you had it, had "pName" outside of "TestReturnVal".
0
BrianFordAuthor Commented:
Thanks,

You are correct I posted the wrong code, I've got 2 apps having this issue and the last post was from the 2nd, sorry about that :)

but as it's the same issue with both your solution may work anyway, so I'll give it a try later and let you know,

thanks again
0
BrianFordAuthor Commented:
Thanks everyone for your help, after much trial and error and then finally downloading SOAPUI it eventually works.

It was a combination of getting the correct XML using SOAPUI and then changing the syntax in XCODE to get the call in the correct format.

Thanks again :)
0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Out of interest, can you post the final code that you needed to get it to work?
0
BrianFordAuthor Commented:
Certainly, here it is:

NSString *soapMsg = [NSString stringWithFormat:
                         @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
                         "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">"
                         "<soap12:Body>"
                         "<TestReturnVal xmlns=\"http://tempuri.org/\">"
                         "<pName>%@</pName>"
                         "</TestReturnVal>"
                         "</soap12:Body>"
                         "</soap12:Envelope>", @"brian"];

Open in new window

0
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Hmmm, it is exactly what I posted above? Am I missing something here?

Why then the need for "much trial and error" and "getting the correct XML using SOAPUI" if I had already given you the correct XML?
0
BrianFordAuthor Commented:
It was a bit strange and possibly just an Xcode parsing issue but initially it didn't work. When pasting in your code above XCode complained about syntax errors and the build failed.

In previous code examples I had got from the web and books, each line had either '\n' or '/\' in order for it to parse correctly, I put those back in and it did build successfully, but when I ran it I got 0 bytes returned.

I then tested the service through SoapUI and it gave me the same code as you but still didn't work through XCode.

I then removed each line terminator one at a time until I arrived back at the code above and it worked, I've no idea why. I can only assume that Xcode was caching the previous build or something like that? but at least it's working now

THanks again for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.