私の wcf Web サービスを使用するものには 2 つの要求があります。彼は、サービスから返されたオブジェクトから逆シリアル化された xml の最初の要素に別の属性が必要です。そして、その xml 要素の既存の属性を変更したいと考えています。
順番に、これはデシリアライゼーションです:
ServiceReference1.MyClient c = new ServiceReference1.MyClient();
ServiceReference1.MyRequest req = new ServiceReference1.MyRequest();
// setting the request
// richiedo la lista - prezzi
ServiceReference1.MyResponse res = c.GetPricesWithTecdocFormat(req);
// serializzation
string OutputPath = this.Request.PhysicalApplicationPath;
System.Runtime.Serialization.DataContractSerializer x = new System.Runtime.Serialization.DataContractSerializer(res.GetType());
using (FileStream fs = new FileStream(OutputPath + "MyResponse.xml", FileMode.Create))
{
x.WriteObject(fs, res);
}
生成された XML ファイルは次のように始まります。
<?xml version="1.0"?>
<MyResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
...
リクエストはこれを持つことです:
<?xml version="1.0"?>
<MyResponse xsi:noNamespaceSchemaLocation="genericResponse.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
それで...
xmlns:i は xmlns:xsi でなければなりません
要素には、.xsd ファイルへの参照を持つ属性が存在する必要があります
私は MessageInspector を試してみましたが、結果はありませんでした-それは私を夢中にさせました...
どのようにできるのか?
ピレッジ