I created a piece of code with which I can create an XML which look like this:
I did this creating a class using XSD.exe on the following XSD:
My question:
If I want to send this xml as a request to a SOAP server, how do I add the SOAP-envelope?
I tried to do this:
1) define a class for the SOAP envelope
When I try to insert my XML thing into this like this:
It fails with an 'InvalidOperati onException' on the xs3.Serialize.
('x2' is the object holding the XML shown earlier...)
Code:
<?xml version="1.0" encoding="utf-8"?>
<test xmlns:test="http://www.test.nl">
<a>A</a>
<b>
<c>1</c>
<c>2</c>
<c>4</c>
<c>3</c>
</b>
</test>
Code:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="test">
<xs:complexType>
<xs:sequence>
<xs:element name="a" type="xs:string" />
<xs:element name="b">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="c" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
My question:
If I want to send this xml as a request to a SOAP server, how do I add the SOAP-envelope?
I tried to do this:
1) define a class for the SOAP envelope
Code:
[XmlInclude(typeof(SOAP))]
[Serializable]
public class SOAP
{
public string Head { get; set; }
public object Body { get; set; }
}
Code:
SOAP x3 = new SOAP { Head = "x1", Body = x2 };
XmlSerializer xs3 = new XmlSerializer(x3.GetType(), "");
XmlWriterSettings xws3 = new XmlWriterSettings();
xws3.Indent = true;
xws3.Encoding = Encoding.UTF8;
XmlWriter xw3 = XmlWriter.Create("test3.xml", xws3);
xs3.Serialize(xw3, x3, namespaces);
('x2' is the object holding the XML shown earlier...)
Comment