我用ASMX编写了一个简单的Web服务,我想在RESPONSE中添加一个自定义标头。 下面是代码。
public class WebService1 : System.Web.Services.WebService
{
public List<CustomerInfo> VerifyCustomerInfo(string Id, string IdType, Char InquiredParty, IndividualPartyAttributes IndividualPartyAttributes, string NonIndividualName, AccountQuery accountQuery)
{
List<CustomerInfo> ciList = new List<CustomerInfo>();
string replycode = "E9999999";
CustomerInfo customer = new CustomerInfo();
customer.IsBankCustomer = true;
customer.CustomerNumber = "111";
ciList.Add(customer);
// TODO: add code here to send replyCode ("E9999999") as custom header in response XML.
return ciList;
}
}
答案 0 :(得分:0)
如果您的意思是SOAP Header,则在WebService方法上添加以下属性:
[SoapHeader("ABC", Direction = SoapHeaderDirection.Out)]
ABC是自定义类。
[XmlRoot("ABC", Namespace = "")]
public class ABC : SoapHeader