I wrote an asmx webSerivce on srv1. I wrote a bll project of an asp.net (original text: an asp.net) project on srv2. Both are hosted under the same web domain
I want to call the asmx from the bll project of the asp.net (original text: asp.net(c#) code behind).
1) I added a web reference, but couldn't find any tutorial how to really call the referenced service.
I have tried:
private void GetTemplateComponentsData() { var service = new ServiceReference.GetTemplateParamSoapClient(); TemplateParamsKeyValue[] responsArray = service.GetTemplatesParamsPerId(id); foreach (var pair in responsArray) { TemplateComponentsData.Add(pair.Key, pair.Value); } }
but get the following error when executing the first line: Could not find default endpoint element that references contract 'ServiceReference.GetTemplateParamSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
What am I missing?
2) I plane to migrate the asp.net proj and asmx together from one domain to another. Is there any way to reference this webservice relatively ?
Adding Reference of the Web Service in Visual Studio 1. Right click the project in Solution Explorer and choose Add Service Reference option from the context menu. 2. Now in the Add Service Reference Dialog you need to click on the Advanced button.
Right click on Connected Services folder (should appear just below your project) and select Add Connected Service. Then select "Add a WCF web service". Put your asmx url into the URI field, set the name space and click Finish. You will now have the reference set.
If you can work with WCF then yes the ASMX services are obsolete because the WCF can fully replace them with more performance and flexibility (multiple binding), functionality.
OK, let me try to rephrase your scenario to make sure I got it right:
The first step is to add a Service Reference to the ASP.NET application by pointing to the WSDL of the ASMX service:
This will do 2 things:
It will modify your web.config and include the client endpoints:
<client> <endpoint address="http://ws.cdyne.com/NotifyWS/phonenotify.asmx" binding="basicHttpBinding" bindingConfiguration="PhoneNotifySoap" contract="ServiceReference1.PhoneNotifySoap" name="PhoneNotifySoap" /> <endpoint address="http://ws.cdyne.com/NotifyWS/phonenotify.asmx" binding="customBinding" bindingConfiguration="PhoneNotifySoap12" contract="ServiceReference1.PhoneNotifySoap" name="PhoneNotifySoap12" /> </client>
Now when you want to invoke this service from your application you will have to choose the endpoint you want to use:
using (var client = new ServiceReference1.PhoneNotifySoapClient("PhoneNotifySoap")) { var result = client.GetVersion(); }
Now simply replace my code snippets with your actual service names.
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