C# 加载SOAP xml时未声明的前缀
我从一个客户端收到了使用以下SOAP请求的文档。我以前从未使用过SOAP,我使用的是问题中列出的解决方案: 然而,当运行C# 加载SOAP xml时未声明的前缀,c#,xml,web-services,soap,C#,Xml,Web Services,Soap,我从一个客户端收到了使用以下SOAP请求的文档。我以前从未使用过SOAP,我使用的是问题中列出的解决方案: 然而,当运行soapEnvelope.LoadXml时,我得到:'head'是一个未声明的前缀。第5行,第39位。 以下是我从客户端收到的SOAP xml: <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2
soapEnvelope.LoadXml
时,我得到:'head'是一个未声明的前缀。第5行,第39位。
以下是我从客户端收到的SOAP xml:
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Header>
<head:CustomCredentials>
<head:UserName>Username</head:UserName>
<head:Password>Password</head:Password>
<head:Source>Code</head:Source>
<head:CurrentCulture>en-CA</head:CurrentCulture>
</head:CustomCredentials>
</soap:Header>
<soap:Body>
<WebServiceMethodName xmlns='Web Service Namespace' />
</soap:Body>
</soap:Envelope>
用户名
密码
代码
恩卡
我不完全确定在这里该做什么。通过谷歌搜索,我相信元素head在名称空间中根本不存在。'head:xxxxxx'元素使用'head'前缀,但没有xmlns:head='???'声明,就像我说的,我只是复制粘贴我收到的内容。我不确定应该如何添加它。请先确定名称空间URI应该在哪里。有人将其定义为SOAP头。一旦您有了这个URI,就将“xmlns:head='{您得到的URL}'添加到顶级元素中(比如xmlns:xsd=..,xmlns:soap=..)