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

M

mike

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).
 
M

mike

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.
 
M

mike

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top