-3

I'm working on asp.net mvc I want to consume secured web service in my project In previous I can consume unsecured web service (asmx) by calling wsdl to create proxy class ,now I tried to create proxy class for the service by using wsdl.exe by using the following formula Wsdl /language:language /protocol:protocol /namespace:myNameSpace /out:filename /username:username /password:password /domain:domain But I had the following error Error: There was an error processing 'https:// .asmx?wsdl'. - There was an error downloading 'https:// .asmx?wsdl' - Unable to connect to the remote server - A socket operation was attempted to an unreachable network ??.???.???.??:??? Can you tell me how can I consume secured web service in my project

Yara

  • Search the web for _"Unable to connect to the remote server - A socket operation was attempted to an unreachable network"_. This has nothing to do with MVC or WCF, but with networking. Check the firewall. – CodeCaster Jul 04 '13 at 12:28

2 Answers2

0

I dont know what sort of service you are talking about but I suspect you are Adding it as a Service/Web reference. If thats the case then assuming its called WebService1 and that the security you are talking about it basic authentication then:

 WebService1 svc = new WebService1();            
 svc.AuthenticationHeaderValue = new WebService1.AuthenticationHeader();
 svc.AuthenticationHeaderValue.UserName = "username";
 svc.AuthenticationHeaderValue.Password = "password";

Try that. As I said I dont have much info on what you are trying to do so its a guess.

Yannis
  • 6,047
  • 5
  • 43
  • 62
  • thanks Mr Yannis for your response , but before write code I need to creat proxy class by using wsdl.exe tool, I tried all possibilities it gave me the following error - There was an error downloading 'http://???.asmx?wsdl'. - The request failed with HTTP status 401: Unauthorized. but I can view this service in browser , can you help me please – Yara Programmer Jul 06 '13 at 08:47
-1

First of all it doesn't matter you are in MVC or any other technology.

If you can call https webservice using simple code, it will do wonders for you.

So first try calling simple HTTPS web service, google and play around it.

For learning purpose and to gain more knowledge, check these links

How to call HTTPS web service method from a .net console application?

Calling a https web service (C#)

http://support.microsoft.com/kb/901183

Community
  • 1
  • 1
Nipun Ambastha
  • 2,553
  • 1
  • 16
  • 26