473,397 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Help adding service reference

Hi,

I was wondering if it was possible to add a service reference to a web
service which requires an SSL certificate to authenticate? If not, if
I have the SSL certificate installed via mmc snap-in, is there another
way to send an XML payload to the web service with an SSL certificatre
attached to the request?

Appreciate any thoughts on this as I am a bit of a newbie.

Thanks
Jun 27 '08 #1
5 7704
Can I check - the issue here is adding the reference in the first
place, yes? In which case, you might try obtaining the metadata
separately; most tools such as wsdl.exe, wse3wsdl.exe (for regular
SOAP and WSE3 SOAP respectively) and svcutil.exe (for WCF) will accept
a .wsdl or .xsd (or .discomap) at the command line. It might not be as
shiny as the VS window, but it'll work (and give you more options
too).

You can normally obtain the wsdl by doing (for example) ?wsdl on an
asmx. WCF has a different protocol (mex), but if it is disabled it
shows you a help screen instead telling you how to enable it.

Marc
Jun 27 '08 #2
If I misunderstood, and the issue is *using* the SSL web-service at
runtime, then you'll need to write some code. For wse/wse3 you can add
to the ClientCertificates collection; for WCF (which is what I
understand for "service reference"), there
is .ClientCredentials.ClientCertificate; either set .Certificate, or
call .SetCertificate(). I think you can also do this via config, but I
can't remember how exactly off-hand.

Marc
Jun 27 '08 #3
On Jun 10, 8:46 am, Marc Gravell <marc.grav...@gmail.comwrote:
If I misunderstood, and the issue is *using* the SSL web-service at
runtime, then you'll need to write some code. For wse/wse3 you can add
to the ClientCertificates collection; for WCF (which is what I
understand for "service reference"), there
is .ClientCredentials.ClientCertificate; either set .Certificate, or
call .SetCertificate(). I think you can also do this via config, but I
can't remember how exactly off-hand.

Marc
Hi Marc,

Thanks for your replies. The web service I am trying to connect to
needs an ssl certificate otherwise I cannot connect to it. I have
tried using the code below but I keep getting "Unable to connect to
the remote server". I have also made sure that it ignores all
certifcate error but that also doesn't work.

webRequest.ClientCertificates.Add(GetCertificate() );

private X509Certificate GetCertificate()
{
///Set store to LocalMachine as this is where the
certificates must be installed
X509Store store = new X509Store(StoreName.My,
StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
///Find certificate based on it's name
X509Certificate2Collection certificates =
store.Certificates.Find(X509FindType.FindBySubject Name, this.sslName,
true);
return certificates[0];

}

The following code which is in the constructor of the class ignores
the ssl cert errors.

ServicePointManager.ServerCertificateValidationCal lback =
TrustAllCertificateCallback;

public static bool TrustAllCertificateCallback(object sender,
X509Certificate cert, X509Chain chain, SslPolicyErrors
errors)
{
return true;
}
Jun 27 '08 #4
Maybe I'm being daft; you mentioned SSL to authenticate, so I was
thinking client certificates; but if you actually mean an ssl (https)
certificate, then just ensure that you connect over https. WCF uses
this approach, and won't accept username/password pairs
(TransportWithMessageCredential) unless the transport provides
encryption.

However, most service code is very picky, and wants that certificate
to be properly trusted. Is this the issue? You don't trust the
certificate the server is issuing? In which case MMC would be your
first port of call (or get a better certificate at the server). In
fact, WCF even demands that the servers agree on the time (UTC)...

Marc
Jun 27 '08 #5
On Jun 10, 10:00 am, Marc Gravell <marc.grav...@gmail.comwrote:
Maybe I'm being daft; you mentioned SSL to authenticate, so I was
thinking client certificates; but if you actually mean an ssl (https)
certificate, then just ensure that you connect over https. WCF uses
this approach, and won't accept username/password pairs
(TransportWithMessageCredential) unless the transport provides
encryption.

However, most service code is very picky, and wants that certificate
to be properly trusted. Is this the issue? You don't trust the
certificate the server is issuing? In which case MMC would be your
first port of call (or get a better certificate at the server). In
fact, WCF even demands that the servers agree on the time (UTC)...

Marc
Hi,

The client SSL certificate is installed correctly and is trusted. The
web service requires that I attach the client SSL certificate with the
https request, if I don't it will not allow me to connect to their
service. I have used the code above which picks the correct
certificate from the certificate store and attaches it, however when I
send the request I get an "Unable to connect to server" message, which
is basically telling me that the certificate wasn't attached. I was
able to do something similar in VB6 using WinHTTP which worked a
treat, but I can't get it to work in C#.

Appreciate any suggestions.
Jun 27 '08 #6

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

Similar topics

2
by: John | last post by:
What si the difference between Adding a Reference and actually dragging and dropping an activeX control onto a form? Thanks John ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure...
2
by: Michael Barrido | last post by:
Greetings! I have a project that needs to access a web service. My problem is this web service is provided via CGI. I cannot do a "Web Reference" to it to add in my dotnet project. I'm planning to...
0
by: Saumendra | last post by:
Hi guys, When I am adding a Web Reference in Visual Studio.net, I provide the url to the .vsdisco file, so that Visual Studio.net can dynamically discover all the available Web Services. Now when...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
1
by: Jeff Dillon | last post by:
I'm using the webservice I've created: http://www.emergencyreporting.com/ERSWebService/ERSDispatch.asmx When building a client VB.NET app, and adding a web reference to the above file, I see...
3
by: MIGUEL | last post by:
Hi all, I'm quite lost with how adding web references to a project creates proxy classes. I've developed a web service with two classes inside and that contains three references to three...
1
by: rgarf | last post by:
I have a web service that is consumed by a C++ application. I added a C# dll reference to the web service, When the web service calls a method on the dll, it sends back an HRESULT of E_FAIL to my...
4
by: glebur | last post by:
Hi, I'm trying to create a web service client in C# but I get stuck at one of the first steps. When adding a Web reference to the Visual Studio project; I get this error (this is a translation,...
0
by: Michael Höhne | last post by:
Hi, we're developing some web services and use the local development server of Visual Studio 2005 to create, run and debug the project. The web service methods connect to a database hosted on a...
4
by: =?Utf-8?B?Z3Jhenph?= | last post by:
Hello If someone can help me with this it would be greatly appreciated. I’m no web service expert but I don't think i'm trying to do anything too special. I think i must be missing something...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.