我正在从我的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>更多推荐
发布评论