Invoking a Web Service via DLL getting this error - c#

I get this error when invoking my dll with SAP B1 Integration Framework:
Could not find default endpoint element that references contract
'MobiService.AccountsSoap' in the Service Model 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.
But when I invoke the DLL via another .NET application it works.
My app config is set:
<client>
<endpoint address="http://191.211.42.100/MobiVendWSTest/accounts.asmx"
binding="basicHttpBinding" bindingConfiguration="AccountsSoap"
contract="MobiService.AccountsSoap" name="AccountsSoap" />
</client>**

You need to copy the entire service configuration from the DLL's app.config to your application's app.config, as DLLs can not have their own app.config.
The application will read its app.config and the DLL will automatically find the settings even though there's no separate config file for it.

Related

unable to run wcf service app with a renamed service?

I have a basic solution and I've added a WCF service lib. I can view the default service created in the browser after the initial wcf service app has been added to the solution. However, after I rename the default wcf service and its interface class and then view the service in the browser, the web page displays the following runtime error:
The type 'MyNewService.Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
However, if I search the project structure for 'Service1' then no references to 'Service1' are returned. Any idea what the root cause of this error might be? It seems like I've been able to do this successfully several times in the past and I don't think that I've ever encountered this roadblock before.
Look in the app.config, look at endpoint->contract, im guessing thats where need to update it.
<system.serviceModel>
<services>
<service name="WcfServiceLibrary1.MyService1">
<endpoint address="" binding="basicHttpBinding"
contract="WcfServiceLibrary1.**IMyService1**">
By default, WCF is configured and exposed via the App.config file of your library. Do a search within your App.config to find the old name and change it to the new.
When you want to change the name of your service in the future, use the refactor name (default ctrl+r, r) operation and it will find the name in the config file for you as well.

project that references another project with WCF service reference - default endpoint not found

I have a project called "AppCore" that I am reusing/referencing in several other projects. AppCore had a method for sending mail via system.net that simplifies emailing. However, I created a WCF service reference (to a service that sends mail in a queue) in the AppCore project, created a test form and was able to use the service just fine. When I create a new project (project name "FeedReader") and reference the AppCore project, however, I get an error: "Could not find default endpoint element that references contract" when attempting to access the WCF service. I think this has something to do with the compiler looking for endpoint info in the FeedReader project app.config file and not getting it from the AppCore project app.config file.
If I reference the WCF service directly from the FeedReader project, the endpoint is found. This would be just fine, however I have a dozen or so other projects I wish to have make this same reference and creating a service reference for all of these and future projects makes management difficult and there's no code reuse (something I wish to avoid).
Is this not possible to do (reference a project that references a WCF service)?
In the AppCore project app.config file, you can see the endpoint (it works fine)
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISendMailService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://mailservice:9999/SendMailService.svc/SendMailService"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISendMailService"
contract="Service_SendMail.ISendMailService" name="BasicHttpBinding_ISendMailService" />
</client>
</system.serviceModel>
Naturally, the other projects don't have endpoints defined as they are referencing AppCore (of which there is a definition). NOTE: I plan on having another few service references in AppCore - but am stuck at just one for now until I can solve this dilemma.

Using class library with WCF service in ASP.NET 5

In my project I have a class library that contains connections for WCF services.
In old ASP.NET MVC in order to use service methods I only needed to add bindings in my web.config and it would work properly.
The issue that I am having now is that when I call web service in ASP.NET5 I get this exception:
InvalidOperationException: Could not find default endpoint element that references contract 'xxx' 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.
Is there a way that I can add my binding in a similar way as I would do in old MVC apps?
I'm using the configuration below from an MVC app. When you add a reference to your WCF service using the add service ref dialog. A client section will get added to your System.ServiceModel section in your web.config. It should specify the endpoint which what seems to be missing based on the error you're getting.
Hope this helps
<client>
<endpoint address="http://address.to.your.service.com:8080/V3/ConfigService.svc"
binding="basicHttpBinding"
bindingConfiguration="ConfigService.V3.ConfigHttpServiceBinding"
contract="ConfigService.IConfigService"
name="ConfigService.V3.ConfigHttpService"/>
</client
I was able to run by programattically config bindings. thanks to #wiktor-zychla comment.
var documentService = new DocumentServiceClient(
new BasicHttpBinding(BasicHttpSecurityMode.None),
new EndpointAddress("http://localhost:60205/DocumentService.svc"));

Does WCF service config info go in client?

I have a question about references to WCF Services. I have two apps:
Console app
--Library
----WCF Service
The console app and library are in the same solution. Because of the WCF service in the library, its app.config has info for the WCF Service.
The console app config has nothing about the WCF Service. The console app calls the WCF Service indirectly through the library. I'm guessing that is why the console app has no WCF info in its config (since it knows nothing about the web service). The console app does a call to a static method in the library, which handles the WCF call.
I'm getting this error on the above call:
Could not find default endpoint element that references contract 'MyServiceReference.IMyService' 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
Does the host (console app) need the WCF Service related info from the library? If so, why didn't VS2010 add it.
The library you created ("--Library", in your hierarchy) likely added a service reference to your WCF service. ("in the library" makes no sense, so I'm assuming that's what you meant). This means that a bunch of information about the WCF service was added to the app.config for the library. That information needs to be in the app.config of any exe that references the library in order for the library to correctly access the WCF Service that it references.
What I'd suggest is running the SVCUtil.exe. You can run it against the running service like this:
svcutil.exe http://localhost:Port/YourSvcClass/YourSvcMethod /language:c#
What that will do is build a client-side c# (or vb) stub class in c#, plus a .Config file with the exact client side configuration file you'd need to connect ... all the good stuff. You can also run svcutil against your WCF dll like this:
svcutil.exe c:\yourfolder\YourService.dll /language:c#
Whether you use the stub class or not, the .config file will be helpful in setting up the client.
Good luck

Generating the System.ServiceModel configuration section for WCF Data Service client

When I use the "Add Service Reference" utility in Visual Studio to connect to a WCF Data Service (OData), visual Studio doesn't generate an App.config file with the System.ServiceModel section for me. (The proxy class is generated fine). Is this normal?
Is there still a way to have this config generated automatically? The WCF service in question is secured and I therefore struggle with authentication issues if I try to to use the command line svcutil.exe with the /config option.
svcutil.exe cannot be used with WCF Data Services (OData), there's a datasvcutil.exe which is used instead.
The Add Service Reference for OData should not generate anything into your app.config as it doesn't need it. To use it, you just new up the generated context class and pass in the URI of the service.
If your OData endpoint required authentication though, the Add Service Reference doesn't support that though, so I'm surprised it works for you.

Categories

Resources