Passing username and password to svcutil.exe?
Asked Answered
S

3

20

We have OSB services that are currently secured with a username and a password. I get a 401 unauthorized when attempting to generate a service proxy using svcutil. I know you need to set up a svcutil.exe.config file but I cannot find any examples except for one that passes a certificate.

Dows anyone know how to send a username and password using svcutil?

Seely answered 22/4, 2010 at 18:25 Comment(0)
C
17

I don't think you can do that.

What you can do in this case is either connect to that address in a browser and just download and save the WSDL file to your local disk and call svcutil.exe on that local copy - or ask the publisher of that webservice to either give you an URL which doesn't require authentication, or to simply send you the relevant WSDL and possibly XSD files so you can create a client side proxy for that service.

Carny answered 25/4, 2010 at 8:42 Comment(1)
I'm validating what you are saying here: msdn.microsoft.com/en-us/library/ms733775.aspx Note: You cannot use configuration to set the user name and password. The configuration shown here must be augmented using code to set the user name and password.Seely
F
12

You can't authenticate in svcutil, but you can set up credentials in Windows for the target machine. Go to your account management page, then to your stored credentials. Add a new entry with the target hostname and credentials. After this, you can use svcutil with the URL.

Facture answered 14/3, 2012 at 13:13 Comment(1)
This works! Very Clever. Thanks. However, as a practical matter, I recommend the OP just download the WSDL! Your code is necessarily coupled to the service interface anyways. If the service interface changes, the small manual step of updating the wsdl file will be trivial compared to modifying or testing your code in connection with the actual changes to the service interface. Manually updating the WSDL gives you control of when this happens. The WSDL is a contract, the consuming party should be aware of when it changes.Calipash
F
-3

Try this. This should work with any web page requiring username and password.

svcutil http://user:password@someurl?wsdl
Francesco answered 16/4, 2014 at 8:12 Comment(1)
I tried this format with the embedded username and password in the URL, but it didn't work.Nagle

© 2022 - 2024 — McMap. All rights reserved.