Dynamic WebService Response in .NET?

Dynamic WebService Response in .NET?

Post by Chri » Sat, 02 Feb 2002 20:37:45



Hi,

Does anybody know how to handle different XML structures in WebService
responses in .NET?
What I mean by this is having two different payloads in the Soap body of the
server response message depending on conditions in the method itself.
For example, if a call is successful, I would like the XML in the Soap body
of the server's response to be:

<Result>Success</Result>

But if there was an error, I would like the response to be:

<Error>
    <UserError>somestring</UserError>
    <TechnicalError>somestring</TechnicalError>
</Error>

This is simple enough with the Soap Toolkit (low-level API), as you simply
generate your own responses, but .NET does it for you.  I have figured out
how to strip the response message from the default <methodnameResponse>
tags, and modify the <methodnameResult> tags to what I want them to be by
using the ParameterStyle attribute and XmlElement, however this means
predefining the response XML structure.

Anyone have any ideas?

Chris

 
 
 

Dynamic WebService Response in .NET?

Post by Michael Giagnocav » Sun, 03 Feb 2002 06:02:48


Not a direct solution, but, to get it right, how would you do this with a normal function?

I'd define a struct and return that.
-Mike


> Hi,

> Does anybody know how to handle different XML structures in WebService
> responses in .NET?
> What I mean by this is having two different payloads in the Soap body of the
> server response message depending on conditions in the method itself.
> For example, if a call is successful, I would like the XML in the Soap body
> of the server's response to be:

> <Result>Success</Result>

> But if there was an error, I would like the response to be:

> <Error>
>     <UserError>somestring</UserError>
>     <TechnicalError>somestring</TechnicalError>
> </Error>

> This is simple enough with the Soap Toolkit (low-level API), as you simply
> generate your own responses, but .NET does it for you.  I have figured out
> how to strip the response message from the default <methodnameResponse>
> tags, and modify the <methodnameResult> tags to what I want them to be by
> using the ParameterStyle attribute and XmlElement, however this means
> predefining the response XML structure.

> Anyone have any ideas?

> Chris


 
 
 

Dynamic WebService Response in .NET?

Post by Chri » Tue, 05 Feb 2002 19:26:19


Hi Michael,

You wouldn't do it in a normal function.  This isn't the same scenario
though, as a webservice method response is a string (the soap message).  I'm
simply querying how to dynamically modify the <soap:body> of that string
response, as you can do using the Soap toolkit.
Because .net hides much of the implementation, it also seems to take away
the functionality to be able to dynamically modify the response as set out
below.

How will defining a struct help?  That will still be one predefined
response, not two...

Chris


> Not a direct solution, but, to get it right, how would you do this with a
normal function?

> I'd define a struct and return that.
> -Mike




Quote:> > Hi,

> > Does anybody know how to handle different XML structures in WebService
> > responses in .NET?
> > What I mean by this is having two different payloads in the Soap body of
the
> > server response message depending on conditions in the method itself.
> > For example, if a call is successful, I would like the XML in the Soap
body
> > of the server's response to be:

> > <Result>Success</Result>

> > But if there was an error, I would like the response to be:

> > <Error>
> >     <UserError>somestring</UserError>
> >     <TechnicalError>somestring</TechnicalError>
> > </Error>

> > This is simple enough with the Soap Toolkit (low-level API), as you
simply
> > generate your own responses, but .NET does it for you.  I have figured
out
> > how to strip the response message from the default <methodnameResponse>
> > tags, and modify the <methodnameResult> tags to what I want them to be
by
> > using the ParameterStyle attribute and XmlElement, however this means
> > predefining the response XML structure.

> > Anyone have any ideas?

> > Chris

 
 
 

Dynamic WebService Response in .NET?

Post by Dima Maltse » Wed, 06 Feb 2002 08:00:15


Hi Chris,

I don't know the answer to your question. Sorry

But I'd like to ask you a question about the
<methodnameResponse> and <methodnameResult> tags. How did
you strip them off? I am trying to do the same thing...

Thanks,
Dima

>-----Original Message-----
>Hi Michael,

>You wouldn't do it in a normal function.  This isn't the
same scenario
>though, as a webservice method response is a string (the
soap message).  I'm
>simply querying how to dynamically modify the <soap:body>
of that string
>response, as you can do using the Soap toolkit.
>Because .net hides much of the implementation, it also
seems to take away
>the functionality to be able to dynamically modify the
response as set out
>below.

>How will defining a struct help?  That will still be one
predefined
>response, not two...

>Chris




>> Not a direct solution, but, to get it right, how would
you do this with a
>normal function?

>> I'd define a struct and return that.
>> -Mike


in message

>> > Hi,

>> > Does anybody know how to handle different XML

structures in WebService

- Show quoted text -

Quote:>> > responses in .NET?
>> > What I mean by this is having two different payloads
in the Soap body of
>the
>> > server response message depending on conditions in
the method itself.
>> > For example, if a call is successful, I would like
the XML in the Soap
>body
>> > of the server's response to be:

>> > <Result>Success</Result>

>> > But if there was an error, I would like the response
to be:

>> > <Error>
>> >     <UserError>somestring</UserError>
>> >     <TechnicalError>somestring</TechnicalError>
>> > </Error>

>> > This is simple enough with the Soap Toolkit (low-
level API), as you
>simply
>> > generate your own responses, but .NET does it for

you.  I have figured
Quote:>out
>> > how to strip the response message from the default

<methodnameResponse>

- Show quoted text -

Quote:>> > tags, and modify the <methodnameResult> tags to what
I want them to be
>by
>> > using the ParameterStyle attribute and XmlElement,
however this means
>> > predefining the response XML structure.

>> > Anyone have any ideas?

>> > Chris

>.

 
 
 

Dynamic WebService Response in .NET?

Post by Dima Maltse » Wed, 06 Feb 2002 08:34:02


I've just found an article that explains how you can
customize Web Services. Here is a link for those who's
interested.

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpguide/html/cpconcustomizingsoapinaspnetwebserviceswebs
erviceclients.asp

Thanks,
Dima

>-----Original Message-----
>Hi Chris,

>I don't know the answer to your question. Sorry

>But I'd like to ask you a question about the
><methodnameResponse> and <methodnameResult> tags. How did
>you strip them off? I am trying to do the same thing...

>Thanks,
>Dima

>>-----Original Message-----
>>Hi Michael,

>>You wouldn't do it in a normal function.  This isn't the
>same scenario
>>though, as a webservice method response is a string (the
>soap message).  I'm
>>simply querying how to dynamically modify the
<soap:body>
>of that string
>>response, as you can do using the Soap toolkit.
>>Because .net hides much of the implementation, it also
>seems to take away
>>the functionality to be able to dynamically modify the
>response as set out
>>below.

>>How will defining a struct help?  That will still be one
>predefined
>>response, not two...

>>Chris




>>> Not a direct solution, but, to get it right, how would
>you do this with a
>>normal function?

>>> I'd define a struct and return that.
>>> -Mike


>in message

>>> > Hi,

>>> > Does anybody know how to handle different XML
>structures in WebService
>>> > responses in .NET?
>>> > What I mean by this is having two different payloads
>in the Soap body of
>>the
>>> > server response message depending on conditions in
>the method itself.
>>> > For example, if a call is successful, I would like
>the XML in the Soap
>>body
>>> > of the server's response to be:

>>> > <Result>Success</Result>

>>> > But if there was an error, I would like the response
>to be:

>>> > <Error>
>>> >     <UserError>somestring</UserError>
>>> >     <TechnicalError>somestring</TechnicalError>
>>> > </Error>

>>> > This is simple enough with the Soap Toolkit (low-
>level API), as you
>>simply
>>> > generate your own responses, but .NET does it for
>you.  I have figured
>>out
>>> > how to strip the response message from the default
><methodnameResponse>
>>> > tags, and modify the <methodnameResult> tags to what
>I want them to be
>>by
>>> > using the ParameterStyle attribute and XmlElement,
>however this means
>>> > predefining the response XML structure.

>>> > Anyone have any ideas?

>>> > Chris

>>.

>.

 
 
 

Dynamic WebService Response in .NET?

Post by Michael Giagnocav » Wed, 13 Feb 2002 00:37:59


With a struct then I'd have both types I wanted to return as fields on the struct, and set one to null.  Isn't there some
post-render events that let you look at the Response stream?  Or is that only for web forms?
-mike

> Not a direct solution, but, to get it right, how would you do this with a normal function?

> I'd define a struct and return that.
> -Mike


> > Hi,

> > Does anybody know how to handle different XML structures in WebService
> > responses in .NET?
> > What I mean by this is having two different payloads in the Soap body of the
> > server response message depending on conditions in the method itself.
> > For example, if a call is successful, I would like the XML in the Soap body
> > of the server's response to be:

> > <Result>Success</Result>

> > But if there was an error, I would like the response to be:

> > <Error>
> >     <UserError>somestring</UserError>
> >     <TechnicalError>somestring</TechnicalError>
> > </Error>

> > This is simple enough with the Soap Toolkit (low-level API), as you simply
> > generate your own responses, but .NET does it for you.  I have figured out
> > how to strip the response message from the default <methodnameResponse>
> > tags, and modify the <methodnameResult> tags to what I want them to be by
> > using the ParameterStyle attribute and XmlElement, however this means
> > predefining the response XML structure.

> > Anyone have any ideas?

> > Chris

 
 
 

Dynamic WebService Response in .NET?

Post by Michael Giagnocav » Thu, 14 Feb 2002 01:41:04


Why not use an ASPX and response.write your own response and use an XmlWriter for help?

Or better, an ASHX module.  If you do what you are talking about, you can't use the VS.NET generated helper code anyways, so...
-mike


> Hi,

> Does anybody know how to handle different XML structures in WebService
> responses in .NET?
> What I mean by this is having two different payloads in the Soap body of the
> server response message depending on conditions in the method itself.
> For example, if a call is successful, I would like the XML in the Soap body
> of the server's response to be:

> <Result>Success</Result>

> But if there was an error, I would like the response to be:

> <Error>
>     <UserError>somestring</UserError>
>     <TechnicalError>somestring</TechnicalError>
> </Error>

> This is simple enough with the Soap Toolkit (low-level API), as you simply
> generate your own responses, but .NET does it for you.  I have figured out
> how to strip the response message from the default <methodnameResponse>
> tags, and modify the <methodnameResult> tags to what I want them to be by
> using the ParameterStyle attribute and XmlElement, however this means
> predefining the response XML structure.

> Anyone have any ideas?

> Chris

 
 
 

1. .NET Add-ins in Excel do not show up in Add-ins

Has anyone been successful in adding custom built-in functions into
Excel via the .net XP Interop assemblies?

According to MS KB 316723, you have to make sure you build the
deployment project for the Current User, not the machine.  I did that.

Also, in the Add-in path for Excel, I added a string called "Automation"
(from a support call to Microsoft) ... but
alas ... no add-in after I install.

Anyone get this to work?

--mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

2. offsetof and POD structs

3. Webservice consummation issue from an pocketPC .net SDE program : abnormal time before the response is get

4. Lotus Notes R6

5. Dynamic proxy generation for webservice in .NET Compact Framework

6. >>> 9 0 % O F F <<<

7. Problem with a Rexx script

8. Creating Office Managed COM Add-Ins with Visual Studio .NET

9. Outlook COM Add-ins With .NET

10. .NET Add-ins -> Setup project build problems

11. Visual Studio .NET Add-Ins

12. Creating Visual Studio .Net Add-Ins