1

I'm not very experienced with SOAP calls, so I'm struggling to get my requests to format correctly. I am creating an instance of my object (using the .wsdl file that was supplied) then serialize it using the below code. However, the object is not wrapped in a soap envelope tag which is causing my request to error. Does anyone know how I can modify this to wrap my object correctly?

    public static string SerializeToXml<T>(T dataToSerialize)
    {
        if (dataToSerialize == null) return null;

        using (StringWriter stringWriter = new StringWriter())
        {
            XmlSerializer serializer = new XmlSerializer(typeof(T));
            serializer.Serialize(stringWriter, dataToSerialize);
            return stringWriter.ToString();
        }
    }
benm912
  • 77
  • 1
  • 7
  • This method is only Xml Serializing the object. There is not no way you can generically create SOAP message for all your cases within this. You would have to write another PrepareSoapHeader, PrepareSoapBody type methods. – Prateek Shrivastava Jan 28 '20 at 00:20
  • 1
    See following posting : https://stackoverflow.com/questions/46722997/saml-assertion-in-a-xml-using-c-sharp/46724392 – jdweng Jan 28 '20 at 10:01
  • Thanks for the responses. Based off the post that has been linked, I'm assuming the best way to do this is to just insert the xml that is generated into a method that defines the soap envelope and body. Something like: " – benm912 Jan 28 '20 at 21:40

0 Answers0