Ask a Question related to ASP.NET Web Services, Design and Development.
-
Christopher Ambler #1
How to return my own XML?
When I create a web service, and create a web method that returns a string,
the output is always framed within a tag that looks like:
<string xmlns="http://ewws.example.com/"> </string>
What I'd really like to do is eliminate this string and form my own XML to
send back.
Is this possible?
Christopher
Christopher Ambler Guest
-
Return me
:confused; I need the html for Dreamweaver 8 that will return a person back to a previous page. They could be coming from any number of previous... -
return SQL ID
one way (I believe to be the best way) is to use a stored procedure and set an output variable to the new SQL ID. a second way is to use a... -
return xml
The following function is used in my webservice which returns a dataset. I now need to return the dataset as xml and have no idea how to do it.... -
goToNetPage, return or not return
hi, I have read in the director's help the netDone() command indicates whether a background loading operation (such as getNetText,... -
Return Key
This may sound like an odd question, but does anyone have a "return" key from a Wallstreet powerbook that they don't need? All i need is the key,... -
Kunal Das #2
Re: How to return my own XML?
Dont know if this is a "best practice", but it works for me, Send it back
via another class. but make sure the secondary class is not the first one
within the namespace, VS.net doesn't like that, it'll say, "The Class
Service1 can be designed, but it is not the first class in the file", so
make sure its something like this:
public class Service1 : System.Web.Services.WebService
{
public Service1()
{
InitializeComponent();
}
[WebMethod]
public URLstr ReturnMyURL()
{
URLstr ustring = new URLstr();
ustring.somestring = "ewws.example.com";
return ustring;
}
public class URLstr
{
public string somestring;
}
Output I got:
<?xml version="1.0" encoding="utf-8" ?>
- <URLstr xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://tempuri.org/">
<somestring>ewws.example.com</somestring>
</URLstr>
Hope this helps.
Kunal
"Christopher Ambler" <chris@ambler.net> wrote in message
news:eH2l3cWfDHA.2364@TK2MSFTNGP09.phx.gbl...string,> When I create a web service, and create a web method that returns a> the output is always framed within a tag that looks like:
>
> <string xmlns="http://ewws.example.com/"> </string>
>
> What I'd really like to do is eliminate this string and form my own XML to
> send back.
>
> Is this possible?
>
> Christopher
>
>
Kunal Das Guest
-
Rimsky #3
Re: How to return my own XML?
Create your own public class with the properties that you
want to return and return that class instead of a
string. For example, lets say that your webmethod
returns customer information. Create the public
class "Customer" with properties Name, ID, ... all of
them can be string, int, etc. Then make your webmethod
return your class, not a string. The result will be
something like
<Customer>
<Name>Test Name</Name>
<ID>1</ID>
</Customer>
Hope this helps.
me, Send it back>-----Original Message-----
>Dont know if this is a "best practice", but it works fornot the first one>via another class. but make sure the secondary class issay, "The Class>within the namespace, VS.net doesn't like that, it'llin the file", so>Service1 can be designed, but it is not the first classthat returns a>make sure its something like this:
>
>public class Service1 : System.Web.Services.WebService
>
>{
>
>public Service1()
>
>{
>
>InitializeComponent();
>
>}
>
>[WebMethod]
>
>public URLstr ReturnMyURL()
>
>{
>
>URLstr ustring = new URLstr();
>
>ustring.somestring = "ewws.example.com";
>
>return ustring;
>
>}
>
>public class URLstr
>
>{
>
>public string somestring;
>
>}
>
>Output I got:
>
> <?xml version="1.0" encoding="utf-8" ?>
>- <URLstr xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>xmlns="http://tempuri.org/">
> <somestring>ewws.example.com</somestring>
> </URLstr>
>Hope this helps.
>
>Kunal
>
>
>
>"Christopher Ambler" <chris@ambler.net> wrote in message
>news:eH2l3cWfDHA.2364@TK2MSFTNGP09.phx.gbl...>> When I create a web service, and create a web methodlike:>string,>> the output is always framed within a tag that looksand form my own XML to>>
>> <string xmlns="http://ewws.example.com/"> </string>
>>
>> What I'd really like to do is eliminate this string>>> send back.
>>
>> Is this possible?
>>
>> Christopher
>>
>>
>
>.
>Rimsky Guest



Reply With Quote

