470,810 Members | 888 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

Can you custom format a SoapHeader By Attributes?

I've written a complex web service in C# to be used by SmartDevices and I'm
trying to reduce size of the message to the absolute minimum to save on cost,
every byte counts etc.

Is there any way to custom format the SoapHeader by Attributes in the Web
service or SoapHeader class?

For simplicity look at the example below...

public DeviceAuthenticationHeader DeviceHeader;

[SoapHeader("DeviceHeader", Direction = SoapHeaderDirection.InOut)]
[WebMethod]
public void SimpleMethod()
{
}

produces

<soap:Header>
<DeviceAuthenticationHeader xmlns="http://www.namespace.net/">
<MessageID>guid</MessageID>
<DeviceIdentifier>string</DeviceIdentifier>
<Password>string</Password>
</DeviceAuthenticationHeader>
</soap:Header>

where by I'm trying to achieve

<soap:Header>
<DH xmlns="http://www.namespace.net/">
<id>guid</id>
<uid>string</uid>
<pwd>string</pwd>
</DH >
</soap:Header>

I know I can just change the class name / properties to achieve the same
result but I'm keen on maintaining my class name and properties.

I've achieved id, uid and pwd by the use of Xml serialisation

[SoapElement("mid")]
[XmlElement("mid")]

but my web reference in the SmartDevice now replaces MessageID with mid so
again I lose my class property name.

Ideally I would want my SoapHeader properties to remain the same on web
service and device

Can this be done?

Cheers in advance
Aug 8 '06 #1
0 1006

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Matthew Harvey | last post: by
3 posts views Thread by StGo | last post: by
4 posts views Thread by Wiktor Zychla | last post: by
1 post views Thread by Eric | last post: by
2 posts views Thread by prabhupr | last post: by
10 posts views Thread by Andy Kendall | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.