P
Pmcg
Hi,
I'm having trouble controlling the Xml content that is created by the
XmlSerializer when i make a web service call from a proxy, i thought the
XmlRootAttribute would take care of this
but it seems to have no bearing on the Xml created by the XmlSerializer when
i attempt to make the web service call. If anyone has figured out how to
control the element name for a type in the
generated Xml i would appreciate a pointer.
Below is a simple version of what i have done, where i have customised the
proxy generated by the wsdl.exe tool, i can get this to work by using the
typeName property for the XmlElementAttribute, but i would prefer to apply
this directly to the class as it is used for multiple methods
Server side
If i have a classes such as
[XmlRootAttribute("A")]
public class ServerLongClassName1
{
public int f1;
}
[XmlRootAttribute("R")]
public class ServerLongClassName2
{
public int f1;
}
and i have a web method like
[WebMethodAttribute(Description=".....")]
public LongClassName2 MyMethod(LongClassName1 arg)
{
.....
}
Client side
[XmlRootAttribute("A")]
public class ClientLongClassName1
{
public int f1;
}
[XmlRootAttribute("R")]
public class ClientLongClassName2
{
public int f1;
}
and i have a web proxy class that looks like
[DebuggerStepThroughAttribute()]
[DesignerCategoryAttribute("code")]
[WebServiceBindingAttribute(Name="XSoap", Namespace="http://Something")]
public sealed class olctg : SoapHttpClientProtocol
{
[SoapDocumentMethodAttribute("http://Something/MyMethod",
RequestNamespace="http://Something",
ResponseNamespace="http://Something",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: XmlElementAttribute("R", IsNullable=true)]
public ClientLongClassName2 MyMethod(ClientLongClassName1 p)
{
// Check parameter
if (req == null)
throw new ArgumentNullException("req");
// Make call
object[] results = this.Invoke("DoLookup", new object[] {req});
return ((GCX.ServiceProxy.OLCTG.bmibaby20040426.Response)(results[0]));
}
}
Thanks in advance
Pat
I'm having trouble controlling the Xml content that is created by the
XmlSerializer when i make a web service call from a proxy, i thought the
XmlRootAttribute would take care of this
but it seems to have no bearing on the Xml created by the XmlSerializer when
i attempt to make the web service call. If anyone has figured out how to
control the element name for a type in the
generated Xml i would appreciate a pointer.
Below is a simple version of what i have done, where i have customised the
proxy generated by the wsdl.exe tool, i can get this to work by using the
typeName property for the XmlElementAttribute, but i would prefer to apply
this directly to the class as it is used for multiple methods
Server side
If i have a classes such as
[XmlRootAttribute("A")]
public class ServerLongClassName1
{
public int f1;
}
[XmlRootAttribute("R")]
public class ServerLongClassName2
{
public int f1;
}
and i have a web method like
[WebMethodAttribute(Description=".....")]
public LongClassName2 MyMethod(LongClassName1 arg)
{
.....
}
Client side
[XmlRootAttribute("A")]
public class ClientLongClassName1
{
public int f1;
}
[XmlRootAttribute("R")]
public class ClientLongClassName2
{
public int f1;
}
and i have a web proxy class that looks like
[DebuggerStepThroughAttribute()]
[DesignerCategoryAttribute("code")]
[WebServiceBindingAttribute(Name="XSoap", Namespace="http://Something")]
public sealed class olctg : SoapHttpClientProtocol
{
[SoapDocumentMethodAttribute("http://Something/MyMethod",
RequestNamespace="http://Something",
ResponseNamespace="http://Something",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: XmlElementAttribute("R", IsNullable=true)]
public ClientLongClassName2 MyMethod(ClientLongClassName1 p)
{
// Check parameter
if (req == null)
throw new ArgumentNullException("req");
// Make call
object[] results = this.Invoke("DoLookup", new object[] {req});
return ((GCX.ServiceProxy.OLCTG.bmibaby20040426.Response)(results[0]));
}
}
Thanks in advance
Pat