Web.Services SoapContext

N

Nina

Compact Framework 2.0 does not include support for WSE 3.0 (Web.Services3).
What can I use instead of SoapContext to pass my credentials?
On Windows application I use C# code:

NewToken.com.digitalpaytech.sandbox.TransactionInfoServiceWse
myPayStationWse = new
NewToken.com.digitalpaytech.sandbox.TransactionInfoServiceWse();

SoapContext myContext = myPayStationWse.RequestSoapContext;
UsernameToken token = new UsernameToken(myUsername, myPassword,
PasswordOption.SendPlainText);
myContext.Security.Tokens.Add(token);
myContext.Security.MustUnderstand = true;

It works fine. How can I connect to secure Web Server from Mobile
application where SoapContext is not available?
 
J

Jeff Hopper

You could use this general procedure on your client before calling a given
web service method:

1) Create a NetworkCredential with the entered username/password; call it
nc, for example.
2) Create an instance of your web service proxy class; call it ws, for
example.
3) Set ws.Credentials = nc and ws.PreAuthenticate = true.
4) Override your web service proxy class's GetWebRequest method and inside
the method add the credentials to the request header. See
http://mark.michaelis.net/Blog/CallingWebServicesUsingBasicAuthentication.aspx
for a good example.

Hope this helps!

Jeff Hopper
Hopper Consulting, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top