I have a ASP .NET MVC app that I want to be able to connect to SOAP API.
I have created a wrapper project were I have my common methods that are working with the API. I have created this wrapper because the file generated by tool is so huge the project build would take ages.
From api doc site:
The tool then generates a single file named EconomicWebService.cs with the proxy code. This file can then be included directly in a project (this can slow down your Visual Studio as it is a rather big file) or built into a dll that can be referenced from your project)
I have referenced this wrapper as dll in my class library (middle layer) that is referenced into my MVC application.
Sadly it is not working, and I am getting this error:
Could not find default endpoint element that references contract 'S2s.Economic.WebService.EconomicWebServiceSoap' 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.
Webconfig
<system.web>
.....
</system.web>
<runtime>
...
</runtime>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="EconomicWebServiceSoap">
<security mode="Transport" />
</binding>
<binding name="EconomicWebServiceSoap1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://api.e-conomic.com/secure/api1/economicwebservice.asmx"
binding="basicHttpBinding" bindingConfiguration="EconomicWebServiceSoap"
contract="PTS.S2s.Economic.WebService.EconomicWebServiceSoap"
name="EconomicWebServiceSoap" />
</client>
</system.serviceModel>
</configuration>
I have managed to find a workarround with manual endpoint setup in the code.
EndpointAddress endpoint = new EndpointAddress( "https://api.e-conomic.com/secure/api1/economicwebservice.asmx" );
Related
I am write an C# library that will use as reference for VBA
This library has service reference for some online product we using
and this service reference require an .config file to be in the same folder as the application/dll
when I use the service reference in .net application all work grate.
But when I use it in Ms access VBA I gets error about variables that are missing and I know they are in the config file.
I was trying few solutions i found but the problem is I cant change the variables in the reference cause we update it every few weeks.
so I have to include the config file with the .dll without change variables in the project.
Thanks,
config sample that the service reference use:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Isoapbinding" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.1.180/soap"
binding="basicHttpBinding" bindingConfiguration="Isoapbinding"
contract="time.Isoap" name="IsoapPort" />
</client>
</system.serviceModel>
</configuration>
I am working on ASP.NET Core web site. My website has a reference on a full framework assembly that uses configuration application settings coming from an old fashioned web.config file, There is no control over this assembly and the code can not be fixed and recompiled
Config file that looks like
<appSettings>
<add key="marketDataServiceEndpointName" value="UatMarketDataService"/>
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DebugBinding"/>
</basicHttpBinding>
<netTcpBinding>
<binding name="ServiceNetTcp"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
sendTimeout="10:00:00"
closeTimeout="10:00:00" openTimeout="10:00:00"
receiveTimeout="10:00:00">
<security mode="None"/>
</binding>
<binding name="loggingService" sendTimeout="00:05:00">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint
address="net.tcp://localhost/Service/Service.svc"
binding="netTcpBinding" bindingConfiguration="loggingService"
contract="ServiceContracts.IService" name="IVisionLoggingService"/>
<endpoint
address="http://localhost:62698/Service.svc"
binding="basicHttpBinding"
bindingConfiguration="DebugBinding"
contract="Service.IService" name="DebugBinding"/>
</client>
I've tried to provide a config file for the assembly like
"MyAssemblyName.dll.config" with all the config parameters.
Unfortunately it seems not reading the config file
.NET Core does not have the configuration system of .NET Framework based on .config files so they won't be respected. Without additional support libraries, calls to the System.Configuration types will even fail at runtime. There is a new configuration system built around the Microsoft.Extensions.Configuration and related NuGet packages. (which can even be used outside of .NET Core / ASP.NET Core)
Also note that .NET Core 2.0 doesn't have any server-side WCF service hosting capability so what you were trying to accomplish wouldn't work even through some other configuration system.
I am currently implementing a plugin for a third party application in C#. The plugin is a library (DLL) and it calls some Web services. So, I created a Service Reference in Visual Studio, which is configured in the app.config file of the plugin as such:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="AuthenticationEndpointImplServiceSoapBinding" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/services/auth"
binding="basicHttpBinding" bindingConfiguration="AuthenticationEndpointImplServiceSoapBinding"
contract="AuthenticationWebService.AuthenticationEndpoint"
name="AuthenticationEndpointImplPort" />
</client>
</system.serviceModel>
</configuration>
I have another project, that I use for testing the plugin. When I call the service from that project, it works fine, provided I have copied the same configuration to this project's app.config file also. But when I build the plugin and run it from within the third party application, I get the following message:
Could not find default endpoint element that references contract
'AuthenticationWebService.AuthenticationEndpoint' 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.
I suspect the reason for the error is the fact that there is no configuration file for the third party application. Do you have any ideas how to work around this?
You could set up your parameters(binding, endpoint, etc.) explicitly in your plugin code after reading them from ordinary text file...
Here you will find some example:
https://msdn.microsoft.com/en-us/library/ms731862(v=vs.110).aspx
I'm using VS2012 and have successfully added a service reference to a web service, lets call it Web Service A. I can connect and interact with that webservice, it all works ok.
There's another version of the webservice (Web Service B) that I need to connect to, it's essentially the same but one is used for live and the other for testing. The URLs are different so I thought I could add a second reference without an issue.
However, when I do add Web Service B everything appears to work fine (web.config is modified etc.) but all my existing code that interacts with Web service A breaks, visual studio acts like it doesn't know what classes I'm trying to instantiate.
Can I have two very similar web references (different URLs) that I can easily switch between by changing the code? I would have thought I could but maybe not?
When you add a Service or Web Reference, along with all the code that VS create, the important bit is this thing in the web.config (or App.Config):
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="TempConvertSoap" />
</basicHttpBinding>
<customBinding>
<binding name="TempConvertSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://www.w3schools.com/webservices/tempconvert.asmx"
binding="basicHttpBinding" bindingConfiguration="TempConvertSoap"
contract="ServiceReferenceA.TempConvertSoap" name="TempConvertSoap" />
<endpoint address="http://www.w3schools.com/webservices/tempconvert.asmx"
binding="customBinding" bindingConfiguration="TempConvertSoap12"
contract="ServiceReferenceA.TempConvertSoap" name="TempConvertSoap12" />
</client>
</system.serviceModel>
The example is from the Temperature Convesion service in w3schools.
In your scenario, you only need to add a single web reference and then, to connect to the other one, change this section, in particular the endpoint -> address attribute; as long as the webservice are IDENTICAL, it will work without problems.
As a bonus, being part of the web.config or app.config, you could use config tranforms to replace this with the proper address when building your Release.
If one is for live and another for test, I would add web.config transformations and then run your code under a 'test' configuration.
More info on web.config transforms here:
http://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx
I am currently working on a WPF Application, using a different project to call a WebService.
When I try to build i get this error:
Could not find default endpoint element that references contract
'VisitorRegistrationWebService.VisitorRegistrationWebServiceSoap' 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.
The app.config from my webservice project is just the same as the one from my WPF project.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="VisitorRegistrationWebServiceSoap" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/webservices/VisitorRegistrationWebService.asmx"
binding="basicHttpBinding" bindingConfiguration="VisitorRegistrationWebServiceSoap"
contract="BasicVisitorRegistrationWebService.VisitorRegistrationWebServiceSoap"
name="VisitorRegistrationWebServiceSoap" />
</client>
</system.serviceModel>
</configuration>
The strange thing is that I can run the project and use the webservice to get data, but the error will not go away, no matter how many times I clean and rebuild my solution.
in error message, contract name is 'VisitorRegistrationWebService.VisitorRegistrationWebServiceSoap'
and in endPoint configuration, contract="BasicVisitorRegistrationWebService.VisitorRegistrationWebServiceSoap"