I have a wpf C# application that calls a web service AddressValidationService. I know it used to work (before I started working on the project), but now it doesn't. The exception happens here:
var addrSvc = new AddressValidationServiceReference.AddressValidationServiceClient();
The exception is:
Could not find default endpoint element that references contract 'AddressValidationServiceReference.IAddressValidationService' 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.
This is from my app.config:
<client>
<endpoint address="http://rdbval/EASTServices/AddressValidationService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPolicyRetriever"
contract="AddressValidationServiceReference.IPolicyRetriever"
name="BasicHttpBinding_IPolicyRetriever" />
<endpoint address="http://rdbval/EASTServices/AddressValidationService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAddressValidationService"
contract="AddressValidationServiceReference.IAddressValidationService"
name="BasicHttpBinding_IAddressValidationService" />
</client>
Maybe somebody could tell what is wrong? Thanks.
Probably stupid guess, but anyway: are you sure your config file is the one from your client application? =). try reading some AppSetting from it for example to ensure you are using the correct one if you are not sure.
The config itself looks fine.
You will need to Insert or Update the endpoints in your .config in the ServiceModel client project for IAddressValidationService
Related
I'm just getting familiar with WCF and I have to add additional functionality to a working web service at work. As I feel the need to be able to test the functionality before deploying it, I decided to build a test client. Here comes the problem.
I created a Console Application just for the purpose of a test client and tried to add a Service Reference through the provided WSDL but it didn't work. There was no config file created.. I tried first the "Add Service Reference" option in VS and when it didn't work, I tried creating the Proxy and Config files with svcutil.exe...
Just the proxy class gets created... When I try to instantiate a "client object" from that class, the following Exception is thrown: "Could not find default endpoint element that references contract 'eOrderingService.IeOrderingService' 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."
As this is a working service (a Czech company is using it), apparently there must be a way to create a web.config or app.config even manually but I have no idea where to start.. As I said I'm just getting familiar with WCF so I started looking online but most of the problems connected somehow to my issue were in different parts of the already created Config files.. I managed to bypass that exception adding the following to app.config:
<system.serviceModel>
<services>
<service name="eOrderingService" >
<endpoint
address="http://localhost:61472/eOrderingService.svc"
binding="webHttpBinding"
contract="eOrderingService.IeOrderingService" >
</endpoint>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp helpEnabled="true" />
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint
address="http://localhost:61472/eOrderingService.svc"
binding="webHttpBinding"
bindingConfiguration=""
contract="eOrderingService.IeOrderingService"
behaviorConfiguration="web"
name="DeliveryNote" >
</endpoint>
</client>
The service has a lot of methods and the one I need to test is called 'DeliveryNote'.
So lets say the service is at this address:
http://localhost:61472/eOrderingService.svc
The POST method I need to call is:
http://localhost:61472/eOrderingService.svc/DeliveryNote
And respectively the GET method is:
http://localhost:61472/eOrderingService.svc/DeliveryNote?DocumentFilter={DOCUMENTFILTER}&CustomerID={CUSTOMERID}&FromDate={FROMDATE}
The links are working but I cannot figure out how to call them from the client.
When I tested calling the POST method I received another exception:
The remote server returned an unexpected response: (400) Bad Request.
That shouldn't be true because the request I'm sending is already tested and is a valid request in XML format.
So I tried to test with a different GET method that works and receives just two DateTime parameters and not a Xml. If I try the following link:
http://localhost:61472/eOrderingService.svc/PriceChanges?startDate=2018-08-29&endDate=2018-08-30
the result is OK..
But if I call the automatically generated method "PriceChanges" the result is NULL.
I just don't get what I do wrong. It seems like a connection to the service is established but the methods are not called/build correctly. Probably because I cannot comprehend how to build the <system.serviceModel> in app.config.
I definitely should read more about the web services but I don't know where to start.
I have created a new WCF project using Visual Studio 2012,
I noticed that there is no Service node in the web.config to define the service and the contract, however i deployed the service to azure and it worked, however I`m getting this error:
The remote server returned an unexpected response: (413) Request Entity Too Large. In Silverlight
so i guess i need to increase the maximum allowed request but how do i do that with no service node ?
Beginning with VS 2010 WCF added the concept of default endpoints (as well as default bindings and behaviors), to simplify configuration.
The details can be found at this link: A Developer's Introduction to Window's Communication Foundation 4
In your case, you'll need to create a binding in your config file that has larger sizes, and either set that as the default binding or assign that binding to an explicitly defined endpoint.
By default WCF (in .NET 4+) will assign request coming in over http to basicHttpBinding. These protocol mappings can also be changed in the config file.
A couple of simple examples to help you (the article I linked goes into more detail):
To create a default binding, simply define the binding and omit the name attribute:
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="10000000" ....>
</basicHttpBinding>
</bindings>
This will make your supplied configuration the default basicHttpBinding for the service(s) using that config.
Alternatively, you can use the name attribute on a binding configuration and then assign it to an defined input. Let's say you have a binding name "MyBinding":
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="MyBinding"
contract="MyService.IMyContract" />
If you want something other than basicHttpBinding for http requests, you can do this in the protocols section:
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="wsHttpBinding" bindingConfiguration="" />
The key in your situation is to you'll need to create the binding with larger values, and then either set it as the default or assign it to an endpoint (which you'll also need to define).
As I said, these are just simple examples to give you an idea, and there's a lot more detail in the article I linked.
I have a service that programmatically creates two net-tcp end points of the same interface but in different scope (they do different things under the hood). Normally when services run as they are supposed to, there is no problem for a client service to discover these two points properly based on the scope of each of them. However since discovery doesn't work across subnets, when testing I usually add manual configuration into my app.config to enable my app successfully register endpoints even if discovery fails (which does). Now how can I configure my app.config so that it would work for my new endpoints?
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<client>
<endpoint
address="net.tcp://myserver:2170/"
binding="netTcpBinding"
contract="IMyServiceInterface"
name="Service1"/>
<endpoint
address="net.tcp://myserver:2173/"
binding="netTcpBinding"
contract="IMyServiceInterface"
name="Service2"/>
</client>
</system.serviceModel>
</configuration>
What if you try to make service clients with this constructor dynamically
public ServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress)
and push different settings manually.
Not sure what exactly is your problem in. I don't see why you look into interfaces on client side, since behavior should be defined on server. As per my understanding, you just need to generate your client class once (it's being done automaticaly by VS) and to use it's constructor like that:
var remoteAddr = "net.tcp://myserver:2173/";
var client = new MyClient("*",remoteAddr);
in your app.config there will be only one configuration, pointing to some default server.
I am connecting a solution to a WCF SOAP based web service. The URL is in the format:
http://upload.pete.vls.com/api/hmlapi.svc
However when I add the reference the configuration comes up with the following:
<client>
<endpoint address="http://upload.pete.vls.com/api/HmlApi.svc/soap"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IHmlApi"
contract="ServiceReference1.IHmlApi" name="BasicHttpBinding_IHmlApi" />
</client>
Im confused as to why when I add the reference with /soap/ on the end it doesnt work. But when I dont add it, the 'add reference' feature finds the service and adds it with a /soap/ anyway.
The URL you are entering (without the soap part) includes information on what types of service transport are offered. VS is choosing soap from that, and saving the proper endpoint address in the config.
That end URL would not be correct for what is being asked for when you are prompted, though. Because it's expecting a URL with information on the service - not the actual endpoint that will eventually get used.
Because your endpoint on the server is probably configured like that
<services>
<service name="YourService">
<endpoint name="mySOAPEndpoint" address="soap" binding="someHttpBinding" contract="IYourService" />
</service>
</services>
Note that the address is "soap" which is the relative path after your service URI (i.e. after the .svc). If you write address="" then your .svc URI is the same as your endpoint address.
I have a problem transmitting a file-sized thingy through WCF which uses the named pipe binding
<netNamedPipeBinding>
<binding name="largeMessage"
maxBufferPoolSize="524288000"
maxReceivedMessageSize="655360000"
maxBufferSize="655360000" >
<readerQuotas maxStringContentLength="655360000"
maxArrayLength="2000001"
maxBytesPerRead="2000001"
maxNameTableCharCount="2000001" />
</binding>
</netNamedPipeBinding>
and this is the service definition
<service name="BusinessService.TaskService"
behaviorConfiguration="BusinessService.TaskServiceBehavior">
<endpoint
address=""
behaviorConfiguration="customEndPointBehavior"
binding="netNamedPipeBinding"
bindingConfiguration="largeMessage"
contract="BusinessServiceContracts.Services.ITaskService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
as can be seen, i've set quite large values for all quotas i've been able to find, and still, i get the "The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element." error in the WCF trace files.
I'm fresh out of ideas where to look next, so has anyone else run into the same or similar problem?
The client configuration was (more or less) the same, but the darn thing just wouldn't work.
But, after I opened the server .config with the WCF Configuration Editor, made no changes, and saved, it magically started working, so my guess is that I had some sort of tag mix-up in the file.
Sorry to bother you.
You probably have two configuration files: one from service implementation, and another for your client application; Can you please post both configurations?
Besides, please read this article: Making Sense of Transport Quotas
OK, you've posted the server-side configuration with the <services> node - look fine to me. How about the client-side configuration? You would have to have something in the <client> node as well - does that reference the same binding configuration as well?
Marc