1

I am trying to add a web service reference to my customer's windows server. I can add it by clicking the Add Service Reference from the menu and type the correct web service url in the address bar. Then I click the GO button to validate the url. It locates the web service perfectly. Then I click the OK button to finish the job.

Then I see that Visual Studio creates a folder called App_WebReference, and puts a file like this Reference.svcmap in that folder.

When I go to the c# code, I am trying to call the web service but I cannot reach it. However this work if I create a local project and do the same things I explained above.

Here is web service url if you want to take a look at it. What am I doing wrong? I don't have any code to display because I couldn't code anything since I cannot reach the web service from c#. What am I supposed to do?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Arif YILMAZ
  • 5,754
  • 26
  • 104
  • 189
  • You should note the namespace when add the Serv reference. And then use that. – H H Jul 01 '13 at 12:00
  • Can you explain _"When I go to the c# code, I am trying to call the webservice but I cannot reach it. However this work if I create a local project and do the same things I explained above."_ a bit more? What is "cannot reach it"? Do you get an error? What is "go to the C# code"? What is the difference between the two projects? How do you _use_ the generated code? – CodeCaster Jul 01 '13 at 12:00
  • @henk-holterman I named the reference "ziraat". in aspx.cs file, I type "ziraat.savetransation()", intellisense doesnt work and it cannot see the "ziraat". I do the same procedures in local project, it works – Arif YILMAZ Jul 01 '13 at 12:04
  • 1
    The term "cannot reach" is usually used in a different way when talking about services (as in: the service is unreachable), but it seems you cannot find the namespace in which the service client is generated. In that case [this question](http://stackoverflow.com/questions/3100458/soap-client-in-net-references-or-examples) looks relevant. – CodeCaster Jul 01 '13 at 12:08
  • thank you very much for your effort. sorry about the English – Arif YILMAZ Jul 01 '13 at 12:13

1 Answers1

2

When you added your Service Reference you gave it the Namespace of ziraat so the following code should access the method you are trying to call:

using (var client = new ziraat.RegisterTransactionSoapClient())
{
    client.SaveTransaction(...);
}

In addition I have seen an issue in Visual Studio where the Service Reference is added but the code generated is incorrect... This might be your issue?! To try a work-around:

  • Right-click on the ziraat service reference item in your Solution Explorer tree
  • Click Configure Service Reference... from the context-menu that appears
  • Make sure that the Reuse types in referenced assemblies check box is NOT ticked
  • Click OK to save the changes

Then try the code sample above again.

Belogix
  • 8,129
  • 1
  • 27
  • 32