dongzhan1948 2016-07-08 06:28
浏览 40

将登录凭据从C#客户端发送到Yii SOAP服务器

So, I have SOAP handling classes from https://soapclient.codeplex.com/SourceControl/latest. Using provided methods, I managed to connect to server and retrieve data, like:

SoapClient client = new SoapClient("http://somelink.someserver.net/~johndoe/gogogo/servis");
    XElement myEle = client.Invoke("getProjekti");

What I need to do next is to provide HTTP authentication i.e. to send login credentials to web server. There is a way of adding Username and Password to a provided SoapHeader:

client.Header = new SoapHeader();
client.Header.Name = "AuthHeader";
client.Header.Add("UserName", "student");
client.Header.Add("PassWord", "student");

And there's the roadblock for me. What to do next? Common sense and programming experience make me think that there should be, hypothetically, request method that will now somehow send that header to web server, like:

bool sendLoginRequestToServer(client)

or something, returning true if login is successful or false otherwise. Despite vigorous search I was only left puzzled, since many people use many methods, most of which I failed to understand. What makes it even more difficult for me is that most of tutorials cover C# WebService, while I have ordinary WinForms GUI application. Solution within aforementioned SoapClient would be preferable, but I would settle for anything that works.

  • 写回答

0条回答 默认 最新

    报告相同问题?