views:

84

answers:

2

Quick simple question really.

I'm sending data to a web service in C# and its giving me XML back. It is a SOAP 1.1 and/or 1.2 web service. I'm not sure how to properly recieve this data and then get the information I need out of it.

Here is my code to send it

try
{
  _webService.ProcessCard(sVariable1, sVariable2);

}
catch ( Exception d )
{

}

And here is what I get back if I manually use the service through a browser

<Response>
  <Result>24</Result>
  <RespMSG>Invalid</RespMSG>
  <ExtData>More Data</ExtData>
</Response>

Here is the service definition:

    public Response ProcessCard(string sVariable1, string sVariable2 ) {
      object[] results = this.Invoke("ProcessCard", new object[] {
        sVariable1,
        sVariable2});
      return ((Response)(results[0]));
    }
A: 

Does that "webService.ProcessCard" method return anything? Does it return a string of XML, or a structured data type?

Show us the method definition for ProcessCard, please!

So the ProcessCard method returns an object of type Response - so you just simply use that:

try
{
    Response myResponse = _webService.ProcessCard(sVariable1, sVariable2);

    // do whatever you like and need to do with myResponse
    .......
}
catch ( Exception d )
{

}

Once you have that "response" object - you can do anything you want with it - store it, show it on screen, do some calculations.....

The whole point of web services (ASP.NET ASMX or WCF) is that you don't have to struggle with angle bracket soup (i.e. lots of low-level XML stuff), but you can focus and concentrate on your real issues and work with neat, useful objects.

Cool, isn't it?

marc_s
Sorry for not clarifying. It a SOAP web service. It returns an object of type response, that's what I'm not sure how to accept and store. If it was a string I'd be ok.I'll add the definition above.I plan to display the data, so I need to access the "Invalid" and the "More Data", etc.
Duk
Worked, thanks!
Duk
A: 

You should be able to do something along the lines of

Response response = _webService.ProcessCard( sVariable1, sVariable2 );
DoSomethingToResult( response.Result );
BioBuckyBall