[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webservices

Getting at raw XML as well as objects

ben curthoys

8/22/2003 2:21:00 PM

Suppose I have a webservice "WidgetWS.asmx", that exposes
one WebMethod that takes an
object "WidgetSearchParameters" as a parameter and returns
an array of "Widget" objects.

If I write a dotNET client for this webservice, and add a
WebReference to my
WebService, then the VS.NET2003 IDE very helpfully creates
a bunch of proxy
classes in the client that represent the public properties
of the
"WidgetSearchParameters" and "Widget" objects.

I can call the method, and manually go through all my
proxy classes and
create output, using code not entirely unlike this:

WidgetWS.WidgetWS AEWS = new WidgetWS.WidgetWS();
WidgetWS.WidgetSearchParameters WSearchParam = new
WidgetWS.WidgetSearchParameters();
WSearchParam .WidgetTypeId = int.Parse
(txtWidgetTypeId.Text);;
WidgetWS.Widget[] Ws = AEWS.GetWidgets(WSearchParam);

foreach (WidgetWS.Widget W in Ws)
{
TableRow r = new TableRow();

TableCell c = new TableCell();
c.Text = W.WidgetName;
r.Cells.Add(c);
c = new TableCell();
c.Text = W.WidgetType();
r.Cells.Add(c);
tblWidgets.Rows.Add(r);
}

and this is very useful and absolutely necessary.

but in certain circumstances, I don't want to go to all
this trouble. What
I'd like to go is get the actual raw XML respose that I
see in my browser
when I hit the "Invoke" button on the standard
autogenerated WebService info
pages, and simply transform it with an XSL and squirt the
result directly at
the user without writing any asp code.

And I can't for the life of me work out how to do this. It
seems that once
you've allowed the Microsoft WebService classes to hide
come of the
complexity of calling a webservice from you, you're never
allowed back to
the raw XML.

Please note that I don't want the WebService to return an
XMLnode or
XMLdocument object - in general I want it to do the proxy
class thing, and
it's just a few cases that it would be cool to use the
XML+XSL to create the
user output.

Thanks in advance.

Ben.


2 Answers

Doug Purdy [MS]

8/23/2003 1:30:00 AM

0

The deserialization process places the XML data into an instance of the
class. This process is not reversible unless you serialize the instance.

You could always just use XmlElement as the parameter -- using the raw XML
and then deserialize this XML into an instance whenever you wanted to do so.
There are a couple of other ways to do this as well -- SoapExtension,
strongly-typed wrapper, etc. but in any case the serialization engine
doesn't keep the XML around.

This posting is provided "AS IS" with no warranties, and confers no rights.

"ben curthoys" <bcurthoys@artifaxsoftware.com> wrote in message
news:05f401c368b8$a7a1dd20$a001280a@phx.gbl...
> What
> I'd like to go is get the actual raw XML respose that I
> see in my browser
> when I hit the "Invoke" button on the standard
> autogenerated WebService info
> pages, and simply transform it with an XSL and squirt the
> result directly at
> the user without writing any asp code.
>
> And I can't for the life of me work out how to do this. It
> seems that once
> you've allowed the Microsoft WebService classes to hide
> come of the
> complexity of calling a webservice from you, you're never
> allowed back to
> the raw XML.
>
> Please note that I don't want the WebService to return an
> XMLnode or
> XMLdocument object - in general I want it to do the proxy
> class thing, and
> it's just a few cases that it would be cool to use the
> XML+XSL to create the
> user output.
>
> Thanks in advance.
>
> Ben.
>
>


Christian Weyer

8/23/2003 1:14:00 PM

0

http://weblogs.asp.n...posts...
I have a sample which does exactly what Doug explains. Showed it at TechEd Europe this year and people seemed to like it. But be aware of the 'implications' (as Doug also mentioned) ...

Cheers,
--
Christian Weyer
Microsoft .NET & Service Oriented Architectures

[Microsoft Regional Director, Germany]
http://www.regionaldir...

* XML Web Services: http://www.xmlwebse...
* Weblog: http://weblogs.asp.n...



> The deserialization process places the XML data into an instance of the
> class. This process is not reversible unless you serialize the instance.
>
> You could always just use XmlElement as the parameter -- using the raw XML
> and then deserialize this XML into an instance whenever you wanted to do so.
> There are a couple of other ways to do this as well -- SoapExtension,
> strongly-typed wrapper, etc. but in any case the serialization engine
> doesn't keep the XML around.
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "ben curthoys" <bcurthoys@artifaxsoftware.com> wrote in message
> news:05f401c368b8$a7a1dd20$a001280a@phx.gbl...
> > What
> > I'd like to go is get the actual raw XML respose that I
> > see in my browser
> > when I hit the "Invoke" button on the standard
> > autogenerated WebService info
> > pages, and simply transform it with an XSL and squirt the
> > result directly at
> > the user without writing any asp code.
> >
> > And I can't for the life of me work out how to do this. It
> > seems that once
> > you've allowed the Microsoft WebService classes to hide
> > come of the
> > complexity of calling a webservice from you, you're never
> > allowed back to
> > the raw XML.
> >
> > Please note that I don't want the WebService to return an
> > XMLnode or
> > XMLdocument object - in general I want it to do the proxy
> > class thing, and
> > it's just a few cases that it would be cool to use the
> > XML+XSL to create the
> > user output.
> >
> > Thanks in advance.
> >
> > Ben.
> >
> >
>
>