1
我創建了一個WCF服務,並且正在使用SOAPUI來發送SOAP請求。明確地在xml根標記中添加名稱空間WCF
下面是請求XML該工具是從我的C#模型生成:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:w3="http://www.w3.org/">
<soapenv:Header />
<soapenv:Body>
<w3:PerformScan>
<w3:request>
<w3:SearchConfiguration>
<w3:ConfidenceThreshold>?</w3:ConfidenceThreshold>
<w3:ResultConfiguration></w3:ResultConfiguration>
<w3:ScanRequest xsi:type="w3:CustomerRequest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<w3:CustomerId>?</w3:CustomerId>
<w3:CustomerName>?</w3:CustomerName>
</w3:ScanRequest>
</w3:SearchConfiguration>
</w3:request>
</w3:PerformScan>
</soapenv:Body>
</soapenv:Envelope>
但使它能夠發揮我需要修改請求XML。下面是修改並使用XML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:w3="http://www.w3.org/">
<soapenv:Header />
<soapenv:Body>
<w3:PerformScan xmlns:w3="http://www.w3.org/">
<w3:request>
<w3:SearchConfiguration>
<w3:ConfidenceThreshold>?</w3:ConfidenceThreshold>
<w3:ResultConfiguration></w3:ResultConfiguration>
<w3:ScanRequest xsi:type="w3:CustomerRequest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<w3:CustomerId>?</w3:CustomerId>
<w3:CustomerName>?</w3:CustomerName>
</w3:ScanRequest>
</w3:SearchConfiguration>
</w3:request>
</w3:PerformScan>
</soapenv:Body>
</soapenv:Envelope>
我怎麼能強迫我的C#模型或怎樣做才能使xmlns:w3="http://www.w3.org/"
中,同時從工具產生autopopulated PerformScan
節點。
兩者都是一樣的,沒有區別。不需要兩次定義相同的名稱空間。 – Rao
是的兩者是相同的。但是我需要在PerformScan或請求節點中添加xmlns:w3 =「http://www.w3.org/」,以使其可行,否則會給出錯誤:屬性'type'具有無效值'w3:CustomerRequest '根據其模式類型'QName' - 'w3'是一個未聲明的前綴。由於我正在使用xsd模式驗證。 –
可能需要在服務器端處理,而不是客戶端。 – Rao