I have to deal with the following problem. I have a SOAP server and a SOAP client both asychron with an SAP system to work. I get queries on all classes filled up with data which I then edit my client to be handed over to them again and again send off (I’m looking for SAP sends me the data available, we will process it, ship it back). The problem is that the generated proxy classes to read and re-read the data differs a little. I am looking for 2 days for a way to REALLY SURE is! Since there are very sensitive data, where not really afford to lose.
Here is an example of the proxy class, the server receives the data.
[GeneratedCode("svcutil", "3.0.4506.2152")]
[Serializable]
[DebuggerStepThrough]
[DesignerCategory("code")]
[XmlType(AnonymousType=true, Namespace="urn:sap-com:document:sap:soap:functions:mc-style")]
public partial class _wsv_cas01d0005p0000013303Response
{
private _wsv_cas01Rs0000012311S[] ec_20KiField;
private _wsv_cas01Rs0000012302S[] ec_21KiField;
private _wsv_cas01Rs0000012303S[] ec_23KiField;
private _wsv_caSafMsgExternalS[] etMessagesField;
private string evCeeRequestIdField;
private int evStatusCodeField;
[XmlArray(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
[XmlArrayItem("item", Form=XmlSchemaForm.Unqualified, IsNullable=false)]
public _wsv_cas01Rs0000012311S[] Ec_20Ki
{
get
{
return this.ec_20KiField;
}
set
{
this.ec_20KiField = value;
}
}
Here is an example of another class, the proxy is to be filled again:
[GeneratedCode("svcutil", "3.0.4506.2152")]
[Serializable]
[DebuggerStepThrough]
[DesignerCategor("code")]
[XmlType(AnonymousType=true, Namespace="urn:sap-com:document:sap:soap:functions:mc-style")]
public partial class _wsv_cas01d0005p0000013203
{
private _wsv_cas01Rq0012210001S[] ic_20KiField;
private _wsv_cas01Rq0012210002S[] ic_21KiField;
private _wsv_cas01Rq0012210003S[] ic_23KiField;
private string ivBoIdField;
private string ivBoTypeCdField;
private string ivCbDestinationField;
[XmlArray(Form=XmlSchemaForm.Unqualified, Order=0)]
[XmlArrayItem("item", Form=XmlSchemaForm.Unqualified, IsNullable=false)]
public _wsv_cas01Rq0012210001S[] Ic_20Ki
{
get
{
return this.ic_20KiField;
}
set
{
this.ic_20KiField = value;
}
}
As you can see the headers are already written for SOAP, so I can not easily change the names of the other client.
With this method, I’ve been spending the XML code of the classes available to make the SOAP messages to log. Naur, unfortunately, the names are just all wrong.
public static string ObjectToXml(object input)
{
string objectAsXmlString;
XmlSerializer xs = new XmlSerializer(input.GetType());
XmlSerializerNamespaces test = new XmlSerializerNamespaces();
using (StringWriter sw = new StringWriter())
{
try
{
xs.Serialize(sw, input);
objectAsXmlString = sw.ToString();
}
catch (Exception ex)
{
objectAsXmlString = ex.ToString();
}
}
return objectAsXmlString;
}
Read the code sent back to the client of the package, I’ve realized so. With the modified XML code it works! As long as one considers the rich result.
XmlSerializer serializer = new XmlSerializer(typeof(_wsv_cas01d0005p0000013203));
_wsv_cas01d0005p0000013203 Requestdaten = (_wsv_cas01d0005p0000013203)serializer.Deserialize(xmlDoc);
So now I’m missing a way to transform the XML, and the variables exist which is not clear so I can fill leave the class. I’ve einges on XPATH and XSD read, but I was not really what I need. Maybe even someone of you ever seen such a similar case, and a tip for me?
PS: I hope that one of the translated text can be read. Unfortunately, my English for such complex cases is simply too complicated.
I have it now, not just the most beautiful way af solved, but since I had used URGENT a solution, I’ve realized now so … The “replace” I like not, but I think it’s just quicker than assuming you have the eternally long XML data into a new node first, then to copy the original …
If someone thinks to do better, please’m thankful for every tip.