Gurus,
I have a scenario in which two web methods take the same class/struct
as parameter.
The class/struct in turn has two members. The first member being used
by both methods remains as a common data member. The second member is a
"object" such that, it will contain custom data based on the method
being invoked. To put things clear, following is the class i am talking
about:
[XmlTypeAttribute(Namespace="http://xxx")]
public class MessageParams
{
[XmlElementAttribute("Credentials")]
public Credential cred;
[XmlElementAttribute("FirstMethodParam",
typeof(FirstMethodDataType))]
[XmlElementAttribute("SecondMethodParam",
typeof(SecondMethodDataType))]
public object Item;
}
Following are the web methods, i was mentioning:
[WebMethodAttribute()]
[SoapDocumentMethodAttribute(Use=SoapBindingUse.Lit eral,
ParameterStyle=SoapParameterStyle.Bare)]
[return: XmlElementAttribute("MessageReceipt", Namespace="http://xxx")]
public WebResp FirstMethod([XmlElementAttribute("Message")]
MessageParams Message)
{
return new object();
}
[WebMethodAttribute()]
[SoapDocumentMethodAttribute(Use=SoapBindingUse.Lit eral,
ParameterStyle=SoapParameterStyle.Bare)]
[return: XmlElementAttribute("MessageReceipt", Namespace="http://xxx")]
public WebResp SecondMethod([XmlElementAttribute("Message")]
MessageParams Message)
{
return new object();
}
When i build and run the webservice, the XML element for the second
member of "MessageParams" namely "Item" is not serialized and
therefore, doesn't appear in the web services test page. For ex:
Following is the result on the webservice test page. This is NOT the
expected result, as the "FirstMethodParam" element is missing below
"Credentials" element.
<soap:Body>
<MessageParams xmlns="http://xxx">
<Credentials>
<LoginName>string</LoginName>
<Password>string</Password>
<CallerUserID>string</CallerUserID>
</Credentials>
</MessageParams>
</soap:Body>
Following is the expected result, as "FirstMethodParam" is appearing
below "Credentials" element.
<soap:Body>
<MessageParams xmlns="http://XXX">
<Credentials>
<LoginName>string</LoginName>
<Password>string</Password>
<CallerUserID>string</CallerUserID>
</Credentials>
<FirstMethodParam>
<Source/>
<Destination/>
</FirstMethodParam>
</MessageParams>
</soap:Body>
Is this possible under webservices?
TIA.
Sek