序列化时父元素和子元素需要相同的默认 xml 命名空间
我希望父元素和子元素具有相同的默认名称空间。我需要这种方式,因为另一端的序列化 xml 看起来就像正在验证数字签名的地方。
[XmlType("Parent", Namespace = "some-default-namespace")]
public class Parent
{
[XmlElement("ChildOne", Namespace = "some-default-namespace", Order = 0)]
public Child1 child1 { get; set; }
[XmlElement("ChildTwo", Namespace = "some-default-namespace", Order = 1)]
public Child2 child2 { get; set; }
}
在 XML Serialize 上,我得到了这个...
<Parent xmlns="some-default-namespace">
<ChildOne>
...
</ChildOne>
<ChildTwo>
...
</ChildTwo>
</Parent>
现在,如果我签署此 XML 并将签名的 xml 作为 SOAP 有效负载发送,此 SOAP 请求有效负载将被反序列化为 JAVA 对象,并且在实际的 Web 服务方法中作为该过程的一部分,它们会序列化JAVA对象转化为xml来验证数字签名。不管出于什么原因,他们的序列化 xml 如下所示。这就是为什么我想以下面的形式签署我可以控制的 xml,
<Parent xmlns="some-default-namespace">
<ChildOne xmlns="some-default-namespace">
...
</ChildOne>
<ChildTwo xmlns="some-default-namespace">
...
</ChildTwo>
</Parent>
如何获得所需的输出?非常感谢任何帮助。
I would like the parent and child element to have the same default namespace. I require this way because the serialized xml at the other end appears like that where the digital signature is being verified.
[XmlType("Parent", Namespace = "some-default-namespace")]
public class Parent
{
[XmlElement("ChildOne", Namespace = "some-default-namespace", Order = 0)]
public Child1 child1 { get; set; }
[XmlElement("ChildTwo", Namespace = "some-default-namespace", Order = 1)]
public Child2 child2 { get; set; }
}
On XML Serialize I get this ...
<Parent xmlns="some-default-namespace">
<ChildOne>
...
</ChildOne>
<ChildTwo>
...
</ChildTwo>
</Parent>
Now, if I sign this XML and send the signed xml as the SOAP payload, this SOAP request payload gets deserialized into JAVA object and in the actual webservice method as part of the process, they serialize the JAVA object into xml to verify the digital signature. Their serialized xml looks as below, for whatever reason. That is why I would like to sign the xml that I have control over in the form as below
<Parent xmlns="some-default-namespace">
<ChildOne xmlns="some-default-namespace">
...
</ChildOne>
<ChildTwo xmlns="some-default-namespace">
...
</ChildTwo>
</Parent>
how can I get the desired output? any help is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论