Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > is there a way to control tag names in generated soap message

Reply
Thread Tools

is there a way to control tag names in generated soap message

 
 
mike
Guest
Posts: n/a
 
      05-12-2005
When I define a webservice:


SOURCE:

[WebMethod]
public string Crunch(string bite)
{
return "{"+ruff.ToLower()+"}";
}

SOAP REQUEST:

<soap:Envelope ..... >
<soap:Body>
<Crunch>
<bite>string</bite>
</Crunch>
</soap:Body>
</soap:Envelope>

SOAP RESPONSE:

<soap:Envelope ...... >
<soap:Body>
<CrunchResponse>
<CrunchResult>string</CrunchResult>
</CrunchResponse>
</soap:Body>
</soap:Envelope>

Is there a simple way to control names for generated tags? For example
changing "CrunchResult" to "Crunch" for return values and changing
"bite" to "Arg" (instead of changing argument name in the source code).

 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      05-12-2005
You can control those via custom attributes applied to the method, parameters
and return value. Here's the XmlElementAttribute docs to get you started:

http://msdn.microsoft.com/library/de...ClassTopic.asp

-Brock
DevelopMentor
http://staff.develop.com/ballen



> When I define a webservice:
>
> SOURCE:
>
> [WebMethod]
> public string Crunch(string bite)
> {
> return "{"+ruff.ToLower()+"}";
> }
> SOAP REQUEST:
>
> <soap:Envelope ..... >
> <soap:Body>
> <Crunch>
> <bite>string</bite>
> </Crunch>
> </soap:Body>
> </soap:Envelope>
> SOAP RESPONSE:
>
> <soap:Envelope ...... >
> <soap:Body>
> <CrunchResponse>
> <CrunchResult>string</CrunchResult>
> </CrunchResponse>
> </soap:Body>
> </soap:Envelope>
> Is there a simple way to control names for generated tags? For example
> changing "CrunchResult" to "Crunch" for return values and changing
> "bite" to "Arg" (instead of changing argument name in the source
> code).
>




 
Reply With Quote
 
 
 
 
mike
Guest
Posts: n/a
 
      05-12-2005
Hello Allen,

Yes, I did look into that and I missed AttributeTargets.ReturnValue.
Now that is in place. How do I use it?

[WebMethod]
public [XmlElement("MYCUSTOM")] string Crunch(string bite)
{
return "{"+ruff.ToLower()+"}";
}

That does not compile. How do I attach an attribute to a return value?

Next, will it change <CrunchResult> to <MYCUSTOM> if this is somehow
above is fixed and attribute is applied correctly.

 
Reply With Quote
 
mike
Guest
Posts: n/a
 
      05-12-2005
Hello Allen,

I asked the question back too quickly without looking around.

[WebMethod]
[return: XmlElement("MYCUSTOM")]
public string Crunch(string bite)
{
return "{"+ruff.ToLower()+"}";
}

works ok now with the seap response as

<soap:Envelope ...... >
<soap:Body>
<CrunchResponse>
<MYCUSTOM>string</MYCUSTOM>
</CrunchResponse>
</soap:Body>
</soap:Envelope>

thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error "A form tag with runat=server must exist" but there is a form tag!! André ASP .Net 2 06-23-2008 07:49 AM
How to add SOAP header to a SOAP message? Peter van der veen ASP .Net Web Services 6 11-14-2006 06:44 PM
Visual Studio 2005 html-view does not recognize the generated html-tag of a custom control Rolf Welskes ASP .Net 3 10-06-2006 06:49 PM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
User Control generated names and javascript Jim Corey ASP .Net 0 06-30-2004 03:26 PM



Advertisments