我在网上搜索过但我没有得到它
这是我的灵活代码:
private function callWS():void{
var ws:WebService = new WebService();
//changed this
ws.addHeader(new SOAPHeader(new QName("uri","header1"),{AUTH:"bla"}));
ws.loadWSDL("http://localhost:49548/test/WebService1.asmx?WSDL");
ws.HelloWorld.addEventListener(ResultEvent.RESULT, onResult);
ws.HelloWorld.addEventListener(FaultEvent.FAULT, onFault);
ws.HelloWorld();
}
private function onResult(e:ResultEvent):void{
}
private function onFault(e:FaultEvent):void{
}
这是我的c#代码(相同的旧默认值):
[WebMethod]
public string HelloWorld()
{
//what to do here?
return "Hello World";
}
如何在c#中使用auth?
答案 0 :(得分:0)
我已经发现了,我会在这里发布,但如果你知道更好的方法,请告诉
弹性代码
private function callWS():void{
var ws:WebService = new WebService();
ws.addHeader(new SOAPHeader(new QName("http://tempuri.org/","Auth"),{usr:"woosh"}));
ws.loadWSDL("http://localhost:49548/test/WebService1.asmx?WSDL");
ws.HelloWorld.addEventListener(ResultEvent.RESULT, onResult);
ws.HelloWorld.addEventListener(FaultEvent.FAULT, onFault);
ws.HelloWorld();
}
在c#中我做了这个
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class WebService1 : System.Web.Services.WebService
{
public Auth auth;
[WebMethod]
[SoapHeader("auth")]
public string HelloWorld()
{
return auth.usr;
}
}
public class Auth : SoapHeader
{
public string usr;
}