I'm trying to add a service reference to a SOAP web service into my ASP.NET MVC application so I'm able to consume the web service from here.
The problem is, that the service reference isn't creating any class or method I can use from my regular app, it's only defining two interfaces and a lot of data types.
Maybe I'm mistaken, but as I'm understanding it, the service reference should create a class that I'd be able to use to call the different methods on the service. Then is my job to translate my business model data to the data types of the web service so I can send parameters to methods and work with their responses.
Am I doing it wrong and should use a different approach to consume external SOAP web services?
Check your Service Reference. Right-click and "Configure Service Reference". Uncheck "Reuse types in referenced assemblies" and let it rebuild the proxies.
In my case I created a Service Reference to my WCF service called "Example". This creates a namespace WebApplication1.Example
.
My WCF service is simply called Service1
which is an implementation of IService1
, which has the 2 default operations and an Add
that I added for funsies.
Once the Service Reference is there, I have a using WebApplication1.Example;
and then in C#, var client = new Service1Client();
. Note that the convention appends "-Client" to my service name, which makes sense, as it's a proxy to the actual service.
From there it's just var x = client.Add(5, 6);
BTW, you may not want a Web Reference. While it may "just work", it's not even close to being the same thing as a Service Reference. Web Reference vs. Service Reference
HTH!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With