locked
Envolope and Header XML question RRS feed

  • Question

  • User1034446946 posted

    Hi

    I am needing to build some XML, so far I have build models which I can turn into xml and its working fine, however i need to wrap it in an envolope, and have a UsernameToken, Username, password, nounce and createdDate, I was thinking this would also be a model and I would simply populate it and convert it with the other models, I was just wondering if this was the correct way of doing it, or is there a better way?

    http://schemas.xmlsoap.org/soap/envelope/

    Any help would be appriciated.

    Monday, May 21, 2018 7:24 PM

All replies

  • User475983607 posted

    Yes, building an object model in C# then serializing the object into XML is a common approach. 

    Anyway, the descriptions sounds alot like SOAP and ASP.NET has SOAP libraries  You do not need to build the libraries yourself just use the tried and true libraries that come with the framework.

    Monday, May 21, 2018 7:35 PM
  • User1034446946 posted

    thanks for the info but what is the common way to add a UsernameToken, since it isn't a normal property and I have to build to token, so i can't use a decorator attribute in the model for it.

    I have seen a few examples which the xml envolope is build in a string, then converted to xml, so

    would it be ok to have the envolope and headers in a string, then use replace to add the tokens etc, then serialise my models into xml then convert to string, then place that in the envolope string and convert to xmldocument?

    or is there a class which is something like a new XMLEnvolope class, then use add to add tokens and headers, then another add for the main body?

    Monday, May 21, 2018 7:46 PM
  • User475983607 posted

    EnenDaveyBoy

    thanks for the info but what is the common way to add a UsernameToken, since it isn't a normal property and I have to build to token, so i can't use a decorator attribute in the model for it.

    I have seen a few examples which the xml envolope is build in a string, then converted to xml, so

    would it be ok to have the envolope and headers in a string, then use replace to add the tokens etc, then serialise my models into xml then convert to string, then place that in the envolope string and convert to xmldocument?

    or is there a class which is something like a new XMLEnvolope class, then use add to add tokens and headers, then another add for the main body?

    SOAP is a protocol.  A token a string.  

    SOAP services provide an interface using a WSDL - Web Service Definition Language.  If you are consuming a SOAP service, you'll need to read the support documents to understand how the service works.   Often it is as simple as creating a Service Reference in Visual Studio.  Creating a service reference builds a proxy object model that you fill and pass to the service.

    Can you explain the problem you are trying to solve?

    Monday, May 21, 2018 8:06 PM
  • User1034446946 posted

    Thanks for the reply, my problem is building the xml for a soap call (not sure if call is the right word), the link in the OP is the standard an example of the xml required as it confirms to that standard.

    the soap setup i think I have it sorted, i just want to make sure I am putting my best foot forward with creating the xml, and not missing something.

    Monday, May 21, 2018 9:54 PM
  • User36583972 posted


    Hi EnenDaveyBoy,

    Thanks for the reply, my problem is building the xml for a soap call (not sure if call is the right word), the link in the OP is the standard an example of the xml required as it confirms to that standard.

    the soap setup i think I have it sorted, i just want to make sure I am putting my best foot forward with creating the xml, and not missing something.

    To produce and consume Web services that use different formatting, the .NET Framework provides an attribute-based mechanism for controlling the format of the XML in the SOAP message.

    You can refer the following article when you creating the format of the XML.

    Customizing SOAP Message Formatting:

    Walkthrough: Customizing the Generation of Service Descriptions and Proxy Classes

    Best Regards,

    Yong Lu

    Monday, May 28, 2018 8:44 AM