什么:和XML:SOAP XML是什么意思?(What does a: and r: in SOAP XML mean?)

编程入门 行业动态 更新时间:2024-10-25 02:30:01
什么:和XML:SOAP XML是什么意思?(What does a: and r: in SOAP XML mean?)

我正在从我的WCF请求中获取XML SOAP响应:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header /> <s:Body> <LoginUserResponse xmlns="http://tempuri.org/"> <LoginUserResult <a:NameFirst i:nil="true" /> <a:NameLast i:nil="true" /> <a:Response> <a:Code>1</a:Code> <a:Message>Invalid Password</a:Message> </a:Response> </LoginUserResult> </LoginUserResponse> </s:Body> </s:Envelope>

什么s:,a:和r :(这里没有显示)是什么意思? 他们需要吗? 响应元素是否按字母顺序排序?

谢谢

I am getting following XML SOAP response from my WCF request:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header /> <s:Body> <LoginUserResponse xmlns="http://tempuri.org/"> <LoginUserResult <a:NameFirst i:nil="true" /> <a:NameLast i:nil="true" /> <a:Response> <a:Code>1</a:Code> <a:Message>Invalid Password</a:Message> </a:Response> </LoginUserResult> </LoginUserResponse> </s:Body> </s:Envelope>

what do s:, a:, and r: (not shown here) mean? Are they required? Are the response elements always ordered alphabetically?

Thanks

最满意答案

s:名称空间前缀是信封根目录中定义的名称空间http://schemas.xmlsoap.org/soap/envelope/ 。

a:名称空间前缀可以引用应该在文档中某处定义的自定义命名空间,我已经在LoginUserResult中添加了它,但它也可以在这一点之上。

i:名称空间前缀可能是指名称空间http://www.w3.org/2001/XMLSchema-instance我也添加了。

由于你没有显示r:我们无法对此发表评论。

他们需要吗? 如果所有节点都是默认命名空间的一部分,则为否,否则为是(但需要定义它们)。

响应元素是否按字母顺序排序? 没有。

PS你可能也想摆脱http://tempuri.org/命名空间。

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header /> <s:Body> <LoginUserResponse xmlns="http://tempuri.org/"> <LoginUserResult xmlns:a="somenamespace" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <a:NameFirst i:nil="true" /> <a:NameLast i:nil="true" /> <a:Response> <a:Code>1</a:Code> <a:Message>Invalid Password</a:Message> </a:Response> </LoginUserResult> </LoginUserResponse> </s:Body> </s:Envelope>

s: namespace prefix is the namespace http://schemas.xmlsoap.org/soap/envelope/ as defined in the Envelope root.

a: namespace prefix could be refering to custom namespace that should defined somewhere in the document, I've added it at the LoginUserResult, but it could be above that point as well.

The i: namespace prefix probably refers to the namespace http://www.w3.org/2001/XMLSchema-instance I've also added that.

As you haven't shown r: we can't comment on that.

Are they required? If all the nodes are part of the default namespace, No, otherwise Yes (but they need to be defined).

Are the response elements always ordered alphabetically? No.

P.S. you might want to get rid of the http://tempuri.org/ namespace as well.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header /> <s:Body> <LoginUserResponse xmlns="http://tempuri.org/"> <LoginUserResult xmlns:a="somenamespace" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <a:NameFirst i:nil="true" /> <a:NameLast i:nil="true" /> <a:Response> <a:Code>1</a:Code> <a:Message>Invalid Password</a:Message> </a:Response> </LoginUserResult> </LoginUserResponse> </s:Body> </s:Envelope>

更多推荐

本文发布于:2023-07-04 16:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1026872.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:XML   SOAP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!