【问题标题】:Correct XML to send for cache web service SOAP header为缓存 Web 服务 SOAP 标头发送正确的 XML
【发布时间】:2012-11-12 16:27:15
【问题描述】:

我创建了一个简单的头类:

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

在 Web 服务中,我确保在 SOAPHEADERS 参数中设置了正确的命名空间:

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>

我收到以下错误:

错误 #6254:需要标记,XML 输入,这是标题,不在 作为 UserName 的子级的正确格式(在第 3 行字符 18 处结束)。

为了正确设置用户名,XML 的正确格式是什么?

【问题讨论】:

    标签: xml web-services soap intersystems-cache intersystems


    【解决方案1】:

    只是需要改变:

    Property UserName As %String;
    

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

    【讨论】:

      【解决方案2】:

      看看这里的例子:http://www.w3schools.com/soap/soap_header.asp

      注意:Header 元素的所有直接子元素都必须是命名空间限定的。

      在此示例中,XML 的格式似乎有点不同,将命名空间嵌套为 Header 属性“Trans”的属性(在他们的示例中)。这可能有点牵强,但我确实看到您的请求没有像这样明确设置命名空间。

      【讨论】:

      • 我用命名空间尝试了他们的示例,但仍然得到相同的结果。
      猜你喜欢
      • 1970-01-01
      • 2012-11-03
      • 1970-01-01
      • 2019-11-02
      • 1970-01-01
      • 2013-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多