ASMX作为WCF服务使用,方法的其他参数集为HEADER,应为HEADER传递什么 [英] ASMX consume as WCF service and additional argumnet of method is HEADER, what should pass for HEADER

查看:134
本文介绍了ASMX作为WCF服务使用,方法的其他参数集为HEADER,应为HEADER传递什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在2008年中使用过ASMX服务.那时,调用方法如下所示:

I had consumed ASMX service in vs 2008. and at that time, calling method is look as below:

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

现在,我在VS2012中使用了相同的ASMX服务,并将其添加为服务引用,因此它作为WCF服务使用.

Now, I have used same ASMX service into VS2012 and added as service reference so, it consumed as WCF service.

现在,方法签名中还有一个名为"HEADER"的附加argumnet.签名如下:

NOw, in method signature has one additional argumnet called - "HEADER". so signature looks as below:

      PostTravelData(Header,TravelTransaction OUT TravelTransactionResponse)

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

Please suggest me what should i pass as Header. i am not clear what should i have to pass as HEADER argument. I tried by passing direclty TOKENID value as header but still not work. Do i have to create object of type "RequestHeader" and keep argumnet as "TokenID" and then pass to the argumnet of that method ?

下面是SOAP wsdl:

Below is the 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>

推荐答案

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

As part of the namespace of the service you added there should be an object for the header.

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

You need to create this object, populate any properties as required and pass this as the parameter.

这篇关于ASMX作为WCF服务使用,方法的其他参数集为HEADER,应为HEADER传递什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆