473,804 Members | 2,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Web.Serv ices Authentication?

Hi,

I am trying to put together a small app that uses one of my company's
web service. Originally I interfaced with this web service using java,
and have the example code. I believe the web service was written with
java. Since this web services uses soap I should have no problems
consuming it from other languages, although I'm having a problem
with .net.

The web service requires authentication. I tried adding the
authentication, but still kept getting an exception with the exception
saying something about "could not process the body of the message". So
I decided to use TcpTrace to figure out what was really going on.

I compared what should be 2 identical calls to the web service, one
from .net, one from java. The only pertinent difference I see is the
parameter "Authorization" . The java web service call contains this,
and the .net one does not.

Based on the response message from the server I did some searching and
found that someone else had run into a similar problem and their
solution was to add the authentication information manually to the
request header, but did not leave a description on how to do that.

Is it possible to manually add the authentication information to the
request? Is there something I'm missing to force .net to authenticate?
Why don't the credentials I added to the web service work? Or is it
something else entirely?

Below is the code I used to make the web service call, the request,
the request made from a good java call, and the response from the
server with the .net call.

Thanks for your help,
Will

This is the code I use for .net (in VB):
webservice = New MyCompanysWebSe rvice()
Dim creds As System.Net.Netw orkCredential = New
System.Net.Netw orkCredential()
creds.UserName = "username"
creds.Password = "password"
webservice.Cred entials = creds
webservice.PreA uthenticate = True
webserice.MyMet hodCall(argumen ts)

This is the resulting call to the web server:
POST /soap/rpc HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client
Protocol 2.0.50727.42)
VsDebuggerCausa lityData: uIDPoyeSbaxKao9 EtV5QrGihJU0AAA AALItHCIPp
+E68IP7kjv5l3vh Ssn2pM0RKn8cJ9x cdWeEACAAA
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Host: localhost:6666
Content-Length: 2598
Expect: 100-continue
Connection: Keep-Alive

<?xml version="1.0" encoding="utf-8"?><soap:Envel ope
xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/"
.....
This is the call that is made from java:
POST /soap/rpc HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related,
text/*
User-Agent: Axis/1.4
Host: localhost:6666
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 3592
Authorization: Basic
dml0YWxfd2luZG9 3c19hZF9hcHA6a1 FPY2tjR3g4eFhjY 2lGT3Y=

<?xml version="1.0" encoding="UTF-8"?><soapenv:En velope
xmlns:soapenv=" http://schemas.xmlsoap .org/soap/envelope/"
....
This is the response I get from the .net call:
HTTP/1.0 500 Internal Server Error
Set-Cookie: ssnid=6896yS4Rv rn2IbkQuOnVJ40m |gwmhc-6666173; path=/;
Content-Type: text/xml;charset=utf-8
Connection: Keep-Alive
Content-Length: 844

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap .org/soap/envelope/"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SO AP-ENV:Client</faultcode>
<faultstring>[ISS.0088.9134] Exception occurred while processing
the body of the message</faultstring>
<faultactor>htt p://localhost:6666/soap/rpc</faultactor>
<detail xmlns:webM="htt p://www.webMethods. com/2001/10/soap/
encoding">
<webM:exception >
<webM:className >com.wm.app.b2b .server.AccessE xception</
webM:className>
<webM:message xml:lang="">[ISS.0084.9004] Access Denied</
webM:message>
</webM:exception>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Mar 28 '07 #1
1 8687
For anyone else who may encounter this issue, or for the curious,
after hours of searching I finally found a definite answer and
example. The link is here: http://mark.michaelis.net/Blog/Calli...ntication.aspx

Basically it's a problem with using .net and a server that's using
webmethods. .net doesn't negotiate the authentication the way web
methods expects it. Check out the link for more detail. The below code
is a partial class which only needs to be included in your project and
you can regenerate your webservice proxy all you want because the
generated code comes out as a partial class. The only requirements are
that you have the Namespace set correctly, along with the class name.

I actually found a small bug in the code provided on the site, and it
was the "Basic " string in the call to GetBytes. If you don't include
the space the converted username/password will be smushed against it
and you will get an error from the server. The server expects
something like:
Authorization: Basic abcdefencodedus ernameandpasswo rdxyz
without the space you get
Authorization: Basicabcdefenco dedusernameandp asswordxyz
and an error from the server about a bad string length.

Thanks to anyone who may have been looking into my problem,
Will

I re-wrote the code in VB to fit along with my project, here is the
code:
Namespace MyWebServiceNam eSpace
Partial Public Class MyWebServiceCla ss
Inherits System.Web.Serv ices.Protocols. SoapHttpClientP rotocol

Protected Overrides Function GetWebRequest(B yVal myUri As Uri)
As System.Net.WebR equest
Dim request As System.Net.Http WebRequest
request = CType(MyBase.Ge tWebRequest(myU ri),
System.Net.Http WebRequest)

If Me.PreAuthentic ate Then
Dim creds As System.Net.Netw orkCredential =
Me.Credentials. GetCredential(m yUri, "Basic")
If Not creds Is Nothing Then
Dim credentialBuffe r() As Byte = New
System.Text.UTF 8Encoding().Get Bytes( _
creds.UserName & ":" & creds.Password)
request.Headers ("Authorization ") = "Basic " &
Convert.ToBase6 4String(credent ialBuffer)
Else
Throw New ApplicationExce ption("No network
credentials")
End If
End If
Return request
End Function
End Class
End Namespace

Mar 28 '07 #2

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

Similar topics

0
1620
by: Skeptical | last post by:
Greetings, This question is related to Microsoft Reporting Services Web service. I tried asking it in RS groups but no one seems to be knowledgeable enough to answer, so I wanted to try my chances here. Thanks... I am trying to get the code below to work with no success, I googled the issue but docs popped up provided little help. Basically I am trying to create a directory in RS that uses Forms authentication. Everything works on the...
7
4808
by: Peter Afonin | last post by:
Hello, I'm using this code to access a network share from an asp.net page: Dim dir As DirectoryInfo = New DirectoryInfo("\\10.0.0.150\FormLib\") Dim files() As FileInfo = dir.GetFiles("*.eps") When I try to do it, I get this error: System.UnauthorizedAccessException: Access to the path
13
1318
by: david | last post by:
I met the security problem. I have developed the form based security for ASP.NET appliation. However, it seems that my window based client for my Web services application can not access to the server side. How to overcome this situation? Thanks David
2
2845
by: Justin Lazanowski | last post by:
I have a windows app that I am writting for some field reps. This app should download and upload specific information to a web service, and cache the information on the local computer when they are not online. I have this part working perfectly however, I would really like to have some sort of authentication to access or upload the data. The users are not logged in to a domain so no authentication token is available. All the...
0
914
by: nospamthanks | last post by:
Hi, I have an existing web site, which is configured to use forms authentication. I'd like to expose a web service from this site to provide admin services for the site, and expose some server functionality. Is it possible to do this using Forms authentication, or will I have to change my authentication model? Thanks,
18
3420
by: troywalker | last post by:
I am new to LDAP and Directory Services, and I have a project that requires me to authenticate users against a Sun Java System Directory Server in order to access the application. I have found dozens of examples of how to authenticate users against Active Directory, but AD seems to be a different animal than Sun Java System Directory Server. Could someone provide me with an example of how to authenticate a user against a Directory...
3
7060
by: Sylvie | last post by:
My Windows Application has two forms, one form contains a grid (lets say Stock Listing), and the other is a form of one stock, contains some edit boxes for one stock's fields.. Is it possible to run application remotely and retrieve grid and form data in some way without accessing directly to database server? Web Services is being used for this purpose I think, Which methods must be used for this ?
3
3962
by: richard.martino | last post by:
On Jun 18, 12:57 pm, "Joe Kaplan" <joseph.e.kap...@removethis.accenture.comwrote: ----------------------- Because when I execute: sendmailproxy.SendEmailRequest(sendmail);
8
13344
by: =?Utf-8?B?TWFuanJlZSBHYXJn?= | last post by:
Hi, I created a web service and hosted it in Windows Services. It is working fine. Now I am trying to implement the X509 certificates for message layer security. But it is throwing the following exception: An unhandled exception of type 'System.ServiceModel.Security.SecurityNegotiationException' occurred in mscorlib.dll
0
9594
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
10599
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10347
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
10090
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
7635
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
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
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
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.