从SOAP消息中删除命名空间

时间:2015-09-11 09:29:39

标签: c# xml soap

我有一个问题..

这是一个XML文档,我必须传递给某个方法。

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Header/>
<SOAP:Body>
<BATMAS03>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<TABNAM>EDI_DC40</TABNAM>
<MANDT>310</MANDT>
<DOCNUM>0000000000006284</DOCNUM>
<DOCREL>740</DOCREL>
<STATUS>30</STATUS>
<DIRECT>1</DIRECT>
<OUTMOD>2</OUTMOD>
<IDOCTYP>BATMAS03</IDOCTYP>
<MESTYP>BATMAS</MESTYP>
<STDMES>BATMAS</STDMES>
<SNDPOR>SAPDVJ</SNDPOR>
<SNDPRT>LS</SNDPRT>
<SNDPRN>DVJCLNT310</SNDPRN>
<RCVPOR>XML</RCVPOR>
<RCVPRT>LS</RCVPRT>
<RCVPRN>DXTCLNT330</RCVPRN>
<CREDAT>20150902</CREDAT>
<CRETIM>193043</CRETIM>
</EDI_DC40>
<E1BATMAS SEGMENT="1">
<MATERIAL>000000000000501104</MATERIAL>
<BATCH>150715L01</BATCH>
<E1BPBATCHCTRL SEGMENT="1">
<DOCLASSIFY>X</DOCLASSIFY>
</E1BPBATCHCTRL>
<E1BP3060_ALLOCATION SEGMENT="1">
<CLASS_TYPE>023</CLASS_TYPE>
<OBJECTKEY>000000000000501104150715L01</OBJECTKEY>
<OBJECTTABLE>MCH1</OBJECTTABLE>
<CLOBJECTKEY>Z_PROIZVOD</CLOBJECTKEY>
<CLASSNUM>Z_PROIZVOD</CLASSNUM>
<CLASSTYPE>023</CLASSTYPE>
</E1BP3060_ALLOCATION>
<E1BP3060_VALUATION_CHAR SEGMENT="1">
<CLASS_TYPE>023</CLASS_TYPE>
<OBJECTKEY>000000000000501104150715L01</OBJECTKEY>
<OBJECTTABLE>MCH1</OBJECTTABLE>
<CLOBJECTKEY>Z_PROIZVOD</CLOBJECTKEY>
<CHARACT>Z_EDICIJA</CHARACT>
<VALUE_CHAR>V001</VALUE_CHAR>
</E1BP3060_VALUATION_CHAR>
</E1BATMAS>
</IDOC>
</BATMAS03>
</SOAP:Body>
</SOAP:Envelope>

首先我将它转换为像这样的字符串

 StringWriter sw = new StringWriter();
 XmlTextWriter xw = new XmlTextWriter(sw);
 XmlDoc.WriteTo(xw);
 string str = sw.ToString();

然后我将该字符串传递给方法。问题是我想删除或传递没有SOAP decleration的字符串,没有这个;

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Header/>
<SOAP:Body>

这就是我想以字符串形式传递的内容:

<BATMAS03>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<TABNAM>EDI_DC40</TABNAM>
<MANDT>310</MANDT>
<DOCNUM>0000000000006284</DOCNUM>
<DOCREL>740</DOCREL>
<STATUS>30</STATUS>
<DIRECT>1</DIRECT>
<OUTMOD>2</OUTMOD>
<IDOCTYP>BATMAS03</IDOCTYP>
<MESTYP>BATMAS</MESTYP>
<STDMES>BATMAS</STDMES>
<SNDPOR>SAPDVJ</SNDPOR>
<SNDPRT>LS</SNDPRT>
<SNDPRN>DVJCLNT310</SNDPRN>
<RCVPOR>XML</RCVPOR>
<RCVPRT>LS</RCVPRT>
<RCVPRN>DXTCLNT330</RCVPRN>
<CREDAT>20150902</CREDAT>
<CRETIM>193043</CRETIM>
</EDI_DC40>
<E1BATMAS SEGMENT="1">
<MATERIAL>000000000000501104</MATERIAL>
<BATCH>150715L01</BATCH>
<E1BPBATCHCTRL SEGMENT="1">
<DOCLASSIFY>X</DOCLASSIFY>
</E1BPBATCHCTRL>
<E1BP3060_ALLOCATION SEGMENT="1">
<CLASS_TYPE>023</CLASS_TYPE>
<OBJECTKEY>000000000000501104150715L01</OBJECTKEY>
<OBJECTTABLE>MCH1</OBJECTTABLE>
<CLOBJECTKEY>Z_PROIZVOD</CLOBJECTKEY>
<CLASSNUM>Z_PROIZVOD</CLASSNUM>
<CLASSTYPE>023</CLASSTYPE>
</E1BP3060_ALLOCATION>
<E1BP3060_VALUATION_CHAR SEGMENT="1">
<CLASS_TYPE>023</CLASS_TYPE>
<OBJECTKEY>000000000000501104150715L01</OBJECTKEY>
<OBJECTTABLE>MCH1</OBJECTTABLE>
<CLOBJECTKEY>Z_PROIZVOD</CLOBJECTKEY>
<CHARACT>Z_EDICIJA</CHARACT>
<VALUE_CHAR>V001</VALUE_CHAR>
</E1BP3060_VALUATION_CHAR>
</E1BATMAS>
</IDOC>
</BATMAS03>

这可能吗?怎么样?谢谢!

0 个答案:

没有答案