【问题标题】:ASMX consume as WCF service and additional argumnet of method is HEADER, what should pass for HEADERASMX 使用 WCF 服务,方法的附加参数是 HEADER,HEADER 应该传递什么
【发布时间】:2014-02-10 07:44:10
【问题描述】:

我在vs 2008中使用过ASMX服务,当时调用方法如下:

      PostTravelData(TravelTransaction)
      //NOTE: property - "TOKENID" was set before calling to this method.

现在,我在 VS2012 中使用了相同的 ASMX 服务并添加为服务引用,所以它作为 WCF 服务使用。

现在,在方法签名中有一个额外的 argumnet,称为 - “HEADER”。所以签名如下:

      PostTravelData(Header,TravelTransaction OUT TravelTransactionResponse)

请建议我应该将什么作为标题传递。我不清楚我应该通过什么作为 HEADER 参数。 我尝试通过将直接 TOKENID 值作为标头传递,但仍然无法正常工作。 我是否必须创建“RequestHeader”类型的对象并将 argumnet 保留为“TokenID”,然后传递给该方法的 argumnet?

下面是 SOAP wsdl:

    <?xml version="1.0" encoding="utf-8"?>
    <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>
     <RequestHeader xmlns="http://www.example.com/Soa/Foundation/">
       <Headers>
        <anyType />
      <anyType />
    </Headers>
    </RequestHeader>
  </soap:Header>
 <soap:Body>
  <TravelTransaction xmlns="http://www.example.com/Soa/Foundation/">
    <TravelTransactionRequest xmlns="http://www.example.com/Soa/Foundation/MessageDefinition.xsd">
      <TravelData>
        <TravelMsg>           
        <IsExcused>boolean</IsExcused>
          <ScheduledMeetingId>int</ScheduledMeetingId>
         <Comment>string</Comment>
         <PostAttForScheduledPeriods>boolean</PostAttForScheduledPeriods>
       </TravelMsg>
        <TravelMsg>
        <IsExcused>boolean</IsExcused>
        <ScheduledMeetingId>int</ScheduledMeetingId>
        <Comment>string</Comment>
        <PostAttForScheduledPeriods>boolean</PostAttForScheduledPeriods>
            </TravelMsg>
           </TravelData>
         </TravelTransactionRequest>
       </TravelTransaction>
      </soap:Body>
   </soap:Envelope>

【问题讨论】:

  • 这不是 WSDL。这只是信息。

标签: wcf web-services asmx webservice-client


【解决方案1】:

作为您添加的服务命名空间的一部分,应该有一个标头对象。

您需要创建此对象,根据需要填充任何属性并将其作为参数传递。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-09
    • 2022-11-12
    • 2012-07-03
    • 2012-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多