473,726 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why does client send two soap messages when Credentials is used?

Hao
There is a wield issue in inspecting the network traffic on the web service
client side. There are two soap calls if credentials are used. The first
call has no credentials and is rejected by the server. The second call has
credentials and works. They are done by .Net behind the scene. No exception
is generated. If I do not pass in credentials or pass in empty crenditials
(empty user id and password), only one soap message is sent.

I could not figure out how to configure the .Net to only send one soap
message. Why does .Net send the first soap message?

Below is my code. The BACnetWSCore is the generated ws client proxy.

In case of web service call with

System.Net.Serv icePointManager .Expect100Conti nue = false;
System.Net.Serv icePointManager .UseNagleAlgori thm = false;
BACnetWSCore service = new BACnetWSCore();
service.Url = address;
service.Credent ials = new System.Net.Netw orkCredential(u serid, password);
service.SomeAPI (); // expect only a soap message is sent, but actually
two are sent. The first one failed while the second one succeeds.

Thanks.
Hao


Mar 16 '07 #1
6 6805
Just use CredentialCache instead of NetworkCredenti als and the
PreAuthenticate property in true.

Take a look to the following article
http://www.code-magazine.com/article...0307071&page=3

"Hao" <Ha*@newsgroup. nospamwrote in message
news:um******** ******@TK2MSFTN GP05.phx.gbl...
There is a wield issue in inspecting the network traffic on the web
service client side. There are two soap calls if credentials are used. The
first call has no credentials and is rejected by the server. The second
call has credentials and works. They are done by .Net behind the scene. No
exception is generated. If I do not pass in credentials or pass in empty
crenditials (empty user id and password), only one soap message is sent.

I could not figure out how to configure the .Net to only send one soap
message. Why does .Net send the first soap message?

Below is my code. The BACnetWSCore is the generated ws client proxy.

In case of web service call with

System.Net.Serv icePointManager .Expect100Conti nue = false;
System.Net.Serv icePointManager .UseNagleAlgori thm = false;
BACnetWSCore service = new BACnetWSCore();
service.Url = address;
service.Credent ials = new System.Net.Netw orkCredential(u serid, password);
service.SomeAPI (); // expect only a soap message is sent, but actually
two are sent. The first one failed while the second one succeeds.

Thanks.
Hao

Mar 17 '07 #2
Hello Hao,

The two-request behavior you saw is due to the authentication process of
windows intergated authentication, and this is a transport layer
authentication behavior rather than webservice code specific behavior.
When performing windows authentication, the client browser will send
request without authentication credential info, and if server-side require
user authentication, it deny the access and then a second request goes. So
far, one means for improve such authentication peformance is to se the
"PreAuthenticat e" header of http request(webserv ice client proxy has a
property for this), however, only limited authentication scheme support
this "PreAuthenticat e" setting. here is a webarticle which has mentioned
this:

#Web Service optimization
http://www.codeproject.com/soap/webs...timization.asp

You can have a look to get more idea.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.


Mar 19 '07 #3
Hao
I've tried both PreAuthenticate to true and using the CredentialCache with
"Basic" schema. Only one messasge was sent, without the authentication
header, and therefore was rejected.
Any clue there? I also tried to override keepalive to either true or false,
did not make any difference.
Thanks.
Hao

"Steven Cheng[MSFT]" <st*****@online .microsoft.comw rote in message
news:kF******** *****@TK2MSFTNG HUB02.phx.gbl.. .
Hello Hao,

The two-request behavior you saw is due to the authentication process of
windows intergated authentication, and this is a transport layer
authentication behavior rather than webservice code specific behavior.
When performing windows authentication, the client browser will send
request without authentication credential info, and if server-side require
user authentication, it deny the access and then a second request goes.
So
far, one means for improve such authentication peformance is to se the
"PreAuthenticat e" header of http request(webserv ice client proxy has a
property for this), however, only limited authentication scheme support
this "PreAuthenticat e" setting. here is a webarticle which has mentioned
this:

#Web Service optimization
http://www.codeproject.com/soap/webs...timization.asp

You can have a look to get more idea.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no
rights.


Mar 19 '07 #4
Thanks for your reply Hao,

For the "PreAuthenticat ion", if you're using basic authentication, it
require client-side supply the basic authentication based credential and
the server-side(IIS application virtual dir) is configured as basic
authentication) . Have you configured the IIS virtual directory to use basic
authentication also?

And no matter set "PreAuthenticat e" to true or false, the first request
will always send non authentication header which result a 401 error, and
the "PreAuthenticat ion" setting will take effect for all sequential
requests (avoid the intial 401 roundtrip). You can refer to the following
MSDN document about the behavior of using "PreAuthenticat e" property:
#HttpWebRequest .PreAuthenticat e Property
http://msdn2.microsoft.com/en-us/lib...uest.preauthen
ticate.aspx
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Mar 20 '07 #5
"Mariano Omar Rodriguez" wrote:
Just use CredentialCache instead of NetworkCredenti als and the
PreAuthenticate property in true.
Don't bother with PreAuthenticate . To make this work properly you will have
to override the GetWebRequest method in your client proxy.

Add something like this to your code (change "YourRefere nce" to the name of
your Web Reference):

class OBACnetWSCore : YourReference.B ACnetWSCore {
protected override WebRequest GetWebRequest(U ri uri) {
HttpWebRequest webRequest = (HttpWebRequest )base.GetWebReq uest(uri);
NetworkCredenti al creds = Credentials as NetworkCredenti al;
if (creds != null) {
string authStr =
((creds.Domain != null) && (creds.Domain.L ength 0) ?
creds.Domain + @"\" : string.Empty) +
creds.UserName + ":" + creds.Password;
authStr = Convert.ToBase6 4String(Encodin g.Default.GetBy tes(authStr));
webRequest.Head ers["Authorizat ion"] = "Basic " + authStr;
}
return webRequest;
}
}

....and then use OBACnetWSCore for your proxy.

/Hans
Mar 31 '07 #6


"Hans Liss" wrote:
"Mariano Omar Rodriguez" wrote:
Just use CredentialCache instead of NetworkCredenti als and the
PreAuthenticate property in true.

Don't bother with PreAuthenticate . To make this work properly you will have
to override the GetWebRequest method in your client proxy.
A comment, just to clarify: PreAuthenticate is what you want, it just
doesn't work properly. It causes the authentication header to be sent
automatically only on *subsequent calls*, never on the first one. The
homemade Authorization header technique i described above really is the best
way to do it right now, and let's just hope that Microsoft decides to
implement a proper PreAuthenticate behaviour sometime soon.

Please note also that, when *not* using this trick, in some situations
(talking with an Axis server, for instance) you will get a protocol error on
the second call, because there is something wrong with the .NET
implementation of HTTP 1.1. In these situations you will have to override the
GetWebRequest method anyway, to force it to use HTTP 1.0.

/Hans
Mar 31 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4459
by: Paul Hutchinson | last post by:
All, I wonder if anyone can help/advise with the following interoperability issue we are encountering? We have a .NET web service that takes an abstract type as parameter. Using it from a .net client works OK. However calling the method from a java client (Websphere 5.0) we see the following error being thrown on the call to the method.
0
2303
by: Bartas | last post by:
Hi, I'am writting a simple SOAP client in python (2.4) using SOAPpy lib. I've met with this problem: when I want to send a list of complex type using some method from WebService(java,WAS), I'v got an exception:
0
1190
by: Johann Blake | last post by:
I have an application that runs on a web server that sends data to clients over a TCP socket. The data comes from a class that has been serialized. The class exists in a library (a DLL). The customer receives this serialized data with a client application I wrote. They also have the same DLL, so that when the data received is deserialized, it will be deserialized into the same type of class that was used on the server. I have a problem...
7
2924
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure out to create a "DataSet" as the return type from the webservice?
2
3569
by: David R | last post by:
I am writing a .NET web services client that is calling an Axis web service. I have two questions. 1. The following code should set the authentication; when I call a method on the web service, the call fails with "bad username/password". // wrWorkReq is the name of the service wrWorkReq.Credentials = new System.Net.NetworkCredential("adolph.ramirez", "xxx");
1
7635
by: Guy | last post by:
I use SmtpClient to send mail. My customer reported that sending mail was throwing an exception on his machine "the SMPT client requires a secure connection or the client was not authenticated". so I now provide credentials with my request, however it sends mail all the time, whichever username or password I use. I even removed the password from my Outlook account options. Sends mail anyway ? Is there a credential cache in Windows...
0
2477
by: kim123 | last post by:
I got to write a c# client will ask a SOAP::Lite server for a list of data. In the request I have to send the following attributes: string, string, array, string, string The SOAP:Lite server is on a UNIX box and there is no wsdl file for me to use. My c# code looks like this: class TestApp {
2
2138
by: bhushanbsc | last post by:
Hi, I am working on a project related to windows pocket pc 5.0 (win32). in that i am trying client-server communicationusing SOAP server. but facing problem on IXMLHTTPRequest. #################### CODE ########################## //included files are,
5
3071
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... I've got a .Net client to a soap service that works for the most part, but there are a couple of things I'd like to improve: 1) the first request to the client wrapper always takes 12-15 seconds even though the web server shows < a half second spent on the request. What takes so much time for the client wrapper to warm up? All subsequent requests, even to the same method, take the half second.
0
8890
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9259
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4785
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.