ASMX作为WCF服务使用,方法的附加参数是HEADER,应该传递给HEADER



与2008年相比,我使用了ASMX服务。此时,调用方法如下所示:

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

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

NOw,在方法签名中有一个额外的argument,称为-"HEADER"。所以签名看起来如下:

PostTravelData(Header,TravelTransaction OUT TravelTransactionResponse)

请建议我应该把什么作为页眉。我不清楚我应该通过什么作为HEADER论点。我尝试将直接TOKENID值作为标头传递,但仍然没有成功。我是否必须创建类型为"RequestHeader"的对象,并将argument保持为"TokenID",然后传递给该方法的argument

下面是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>

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

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

最新更新