Returning Bare Type

R

R. K. Wijayaratne

Hi everyone,

We have a web method which returns the following type:


public class methodNameResult
{
public string responseCode = null;
public string details = null;
}


Here is the web-method that returns the above:


[SoapDocumentMethod("",
Use = System.Web.Services.Description.SoapBindingUse.Encoded,
ParameterStyle = SoapParameterStyle.Bare)]
public methodNameResult OurWebMethod(...)
{
...
}


Here is what the actual returned XML from the above web-method looks
like:


<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/
encoding/">
<types:methodNameResult id="id1">
<responseCode xsi:type="xsd:string">...</responseCode>
<details xsi:type="xsd:string">...</details>
</types:methodNameResult>
</soap:Body>


How can we ensure that the returned XML doesn't have
'<types:methodNameResult id="id1">' and '</types:methodNameResult>' in
it? We would rather specify it directly at the web-service rather than
removing / modifying the XML using a SoapFilter for example.

We are using .NET FW 2.0 and WSE 3.0.

Thank you,

RKW.
http://www.codinghelper.org/
 
J

John Saunders [MVP]

R. K. Wijayaratne said:
Hi everyone,

We have a web method which returns the following type:


public class methodNameResult
{
public string responseCode = null;
public string details = null;
}


Here is the web-method that returns the above:


[SoapDocumentMethod("",
Use = System.Web.Services.Description.SoapBindingUse.Encoded,
ParameterStyle = SoapParameterStyle.Bare)]
public methodNameResult OurWebMethod(...)
{
...
}


Here is what the actual returned XML from the above web-method looks
like:


<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/
encoding/">
<types:methodNameResult id="id1">
<responseCode xsi:type="xsd:string">...</responseCode>
<details xsi:type="xsd:string">...</details>
</types:methodNameResult>
</soap:Body>


How can we ensure that the returned XML doesn't have
'<types:methodNameResult id="id1">' and '</types:methodNameResult>' in
it? We would rather specify it directly at the web-service rather than
removing / modifying the XML using a SoapFilter for example.

Are you trying to get just the responseCode and details returned? If that's
the case, then you shouldn't try to return a methodNameResult. Instead, try
returning the two values as "out" parameters:

[WebMethod]
public void OurWebMethod(..., out string responseCode, out string details)
{
}
 
R

R. K. Wijayaratne

Hi John,

Thank you very much, that did the trick!

RKW.

John Saunders said:
R. K. Wijayaratne said:
Hi everyone,

We have a web method which returns the following type:


public class methodNameResult
{
public string responseCode = null;
public string details = null;
}


Here is the web-method that returns the above:


[SoapDocumentMethod("",
Use = System.Web.Services.Description.SoapBindingUse.Encoded,
ParameterStyle = SoapParameterStyle.Bare)]
public methodNameResult OurWebMethod(...)
{
...
}


Here is what the actual returned XML from the above web-method looks
like:


<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/
encoding/">
<types:methodNameResult id="id1">
<responseCode xsi:type="xsd:string">...</responseCode>
<details xsi:type="xsd:string">...</details>
</types:methodNameResult>
</soap:Body>


How can we ensure that the returned XML doesn't have
'<types:methodNameResult id="id1">' and '</types:methodNameResult>' in
it? We would rather specify it directly at the web-service rather than
removing / modifying the XML using a SoapFilter for example.

Are you trying to get just the responseCode and details returned? If that's
the case, then you shouldn't try to return a methodNameResult. Instead, try
returning the two values as "out" parameters:

[WebMethod]
public void OurWebMethod(..., out string responseCode, out string details)
{
}
 

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

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top