怎么把webservice头验证加入到wsdl中
1个回答
推荐于2016-02-17
展开全部
首先,要创建一个继承自System.Web.Services.Protocols.SoapHeader的RequestSOAPHeader类,在其中添加UserName和Password两个属性,代码如下:
public class RequestSOAPHeader : System.Web.Services.Protocols. SoapHeader
{
public string user { get; set; }
public string password { get; set; }
}
生成的WebService代理类中设置成属性成员:
public partial class ISysNotifyTodoWebServiceService
{
public RequestSOAPHeader RequestSOAPHeader { get; set; }
}
在访问的WebService方法上方添加SOAPHeader的声明:
[System.Web.Services.Protocols. SoapDocumentMethodAttribute( "", RequestNamespace="http://webservice.notify.sys/" , ResponseNamespace="http://webservice.notify.sys/" , Use=System.Web.Services.Description.SoapBindingUse .Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle .Wrapped)]
[ return: System.Xml.Serialization. XmlElementAttribute( "return", Form=System.Xml.Schema.XmlSchemaForm .Unqualified)]
[ SoapHeader( "RequestSOAPHeader")]
public notifyTodoAppResult setTodoDone([System.Xml.Serialization.XmlElementAttribute (Form=System.Xml.Schema.XmlSchemaForm .Unqualified)] notifyTodoRemoveContext arg0) {
object[] results = this.Invoke( "setTodoDone", new object[] {
arg0});
return (( notifyTodoAppResult)(results[0]));
}
public class RequestSOAPHeader : System.Web.Services.Protocols. SoapHeader
{
public string user { get; set; }
public string password { get; set; }
}
生成的WebService代理类中设置成属性成员:
public partial class ISysNotifyTodoWebServiceService
{
public RequestSOAPHeader RequestSOAPHeader { get; set; }
}
在访问的WebService方法上方添加SOAPHeader的声明:
[System.Web.Services.Protocols. SoapDocumentMethodAttribute( "", RequestNamespace="http://webservice.notify.sys/" , ResponseNamespace="http://webservice.notify.sys/" , Use=System.Web.Services.Description.SoapBindingUse .Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle .Wrapped)]
[ return: System.Xml.Serialization. XmlElementAttribute( "return", Form=System.Xml.Schema.XmlSchemaForm .Unqualified)]
[ SoapHeader( "RequestSOAPHeader")]
public notifyTodoAppResult setTodoDone([System.Xml.Serialization.XmlElementAttribute (Form=System.Xml.Schema.XmlSchemaForm .Unqualified)] notifyTodoRemoveContext arg0) {
object[] results = this.Invoke( "setTodoDone", new object[] {
arg0});
return (( notifyTodoAppResult)(results[0]));
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询