2012-11-12 59 views
1

我創建了一個簡單的頭類:正確的XML爲緩存Web服務的SOAP頭髮送

Class Sample.Headers Extends %SOAP.Header 
{ 
    Parameter NAMESPACE = "http://tempuri.org"; 
    Property UserName As %String; 
} 

在我提出一定要設置正確的命名空間中SOAPHEADERS參數的Web服務:

Parameter SOAPHEADERS = "UserName:Sample.Headers"; 

我送使用了SoapUI以下XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org"> 
    <soapenv:Header> 
     <tem:UserName>This is the header</tem:UserName> 
    </soapenv:Header> 
    <soapenv:Body> 
     <tem:Test> 
     <!--Optional:--> 
     <tem:argAge>10</tem:argAge> 
     </tem:Test> 
    </soapenv:Body> 
</soapenv:Envelope> 

我得到以下錯誤:

ERROR #6254: Tag expected, XML input, This is the header, is not in proper format as child of UserName (ending at line 3 character 18).

什麼是正確的XML格式,以便UserName設置正確?

回答

1

只是需要改變:

Property UserName As %String; 

Property UserName As %String(XMLPROJECTION = "CONTENT", MAXLEN = 50); 
0

在例如採取偷看在這裏:http://www.w3schools.com/soap/soap_header.asp

Note: All immediate child elements of the Header element must be namespace-qualified.

這似乎是XML的格式在本例有點不同,嵌套命名空間的Header屬性的屬性「跨」(在他們的例子中)。這可能是一個延伸,但我確實看到你的請求沒有像這樣明確地設置名稱空間。

+0

我想他們的榜樣與命名空間,我仍然得到同樣的結果。 –