0

Hi I have a web service method that I have to call from my project; but I am not allowed to add service reference to my visual studio. Could you please advice how can I achieve it. The following link I have given to access AuthenticateUser() method

http://devaspserver.dev.local/IntegrationSerive/Services/GlobalService.svc?wsdl

   [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public string AuthenticateUser(string RequestingUser, string UserPassword, out bool Output) 
{

      // Web service methods code here checking the users authentication

}

Here in the following method trying to call

public bool IsValidUser(string UserID, string Password)
{
   // Here call web service method to validate user

}
  • 1
    Why aren't you allowed to? – EJoshuaS - Stand with Ukraine Aug 17 '16 at 12:56
  • 1
    You create a raw HTTP POST request with the correct headers and XML content and send it. Which is why people generate proxies instead of trying to generate the XML by hand. The restriction is meaningless. Are you sure you understood the restriction correctly? – Panagiotis Kanavos Aug 17 '16 at 12:57
  • I am not allowed: because its required configurable link (URL) – user3624511 Aug 17 '16 at 12:59
  • Why is that important? Why would you arbitrarily move your web service? it seems like a bizarre requirement to me, especially since doing what you've described is much more error-prone. @PanagiotisKanavos is perfectly correct that that's a really bad idea - there's a *lot* of extra work and it's much more error-prone. If you just add the service reference the compiler will take care of a lot of the "plumbing" for you plus it allows the compiler to do more static checking of your calls. – EJoshuaS - Stand with Ukraine Aug 17 '16 at 13:04
  • I will need different service references for dev, test and UAT. to resolve that issue would be great if I can carry on without service reference – user3624511 Aug 17 '16 at 13:06
  • So create separate builds for different environments, it's a lot easier than what you're describing. – EJoshuaS - Stand with Ukraine Aug 17 '16 at 13:07
  • 1
    service reference is essential. you can change it dynamically using this http://stackoverflow.com/questions/5036308/dynamically-switch-wcf-web-service-reference-url-path-through-config-file though i would create seperate builds for each environment – Sujit.Warrier Aug 17 '16 at 13:08
  • 1
    You *DON'T* need to hard-code the service's URL. Just pass a different URL when you create your client. Although you can just change the URL in your config file. Whatever your application, you'll see that your app.config/web.config *already* contains an element with the service's URL. Just use a different config file for production – Panagiotis Kanavos Aug 17 '16 at 13:08
  • How can I create service without " hard-code" into Add Service Reference Dialogue – user3624511 Aug 17 '16 at 13:17
  • See the instructions in the link @Mysterio11 provided - I think that that should solve your problem. You can use their code and just get the URL from App.config or some other source like that. If you have to use a hardcoded DLL you could always create separate builds for each environment but I think his solution's better. – EJoshuaS - Stand with Ukraine Aug 17 '16 at 13:17
  • In the given link its I am not clear about MyClient client ... MyClient client = new MyService.MyClient(); – user3624511 Aug 17 '16 at 13:21
  • add the reference first create a client using that reference then change the url as shown in the figure – Sujit.Warrier Aug 17 '16 at 13:22
  • can not see any figure in your given link – user3624511 Aug 17 '16 at 13:25

0 Answers0