wcf service runs on browser and on form app but got an error on .netcore project while adding service reference - asp.net-core

I got an error while I was adding wcf service on .net core project.Service runs on another project and it runs on the projects under same solution I can add the reference but it is not working on another project. I got the error which I added below.Also service returns wsdl when I call from browser.
An error occurred while attempting to find services at 'http://127.0.0.1:8291/restrictedzone/mex'.
There was no endpoint listening at http://127.0.0.1:8291/restrictedzone/mex that could accept the message.
This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details.

Related

Cannot connect to WCF Web Service Reference in DotNet Core 3.1

There is an issue for connecting to my WCF service from dotnet core 3.1 . For adding service reference I'm using Add Connected Service and then enters WCF URI http://10.10.10.10:8330/mywcfservice. If I enter the remote address as I said before it works fine and server asks for authenticate my request. but after I entered my credentials, in status box it said:
An error occurred while attempting to find services at '10.10.10.10/mywcfservice'. The remote server returned an error:(400) Bad Requst.
If I add / after WCF URI, in status box it said:
An error occurred while attempting to find services at '10.10.10.10/mywcfservice/'. The remote server returned an error:(401) Unauthorized.
I tested my WCF Service with WCF Storm and it works just fine. On the other hand I can connect to WCF Service from .Net Standard Project like a charm. So where is the problem?
Based on the information you provided, I cannot know what happened to your server. You can refer to this link to record the error that occurred on the server-side:
Trying to add a service reference results in Bad Request (400) in one project, otherwise runs fine
Another solution is to use dotnet-svcutil command:
Use a browser to access the WSDL file of the service, and then save it locally.
Then use the dotnet-svcutil command to generate the proxy class.
Finally, add the proxy class to the project.
To use the proxy class also need to add these two packages:
Call WCF service in core:
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress("http://localhost:8000/GettingStarted/CalculatorService");
CalculatorClient calculatorClient = new CalculatorClient(binding,endpointAddress);
Another thing to note is that there are some WCF functions that are not supported in core. For details, please refer to the link below:
WCF service works in MVC client but not in .Net Core 3 client
Feel free to let me know if the problem persists.

Host up and running , but service reference cannot be created from client

I have a console app that is hosting the service by WCF's ServiceHost object, but from the client cannot add the service reference and I am getting the following error:
The URI prefix is not recognized.
Metadata contains a reference that cannot be resolved:
'net.tcp://localhost:8001/Alu'.
There was no endpoint listening at net.tcp://localhost:8001/Alu
that could accept the message. This is often caused by an incorrect address
or SOAP action. See InnerException, if present, for more details.
If the service is defined in the current solution, try building the solution
and adding the service reference again.
I have also activate the WCF Non-Http stuffs in the control panel. Where should be looked into the address this issue?

Testing a WCF Service

I have a few questions about setting up and running a WCF service after done coding it.
I've created my service. I'm able to right-click it in VS and choose to run it in the browser and it comes up.
Now I want to test tie service by creating a new C# project and adding a service reference to my service (.svc).
When I try to add the service reference it can't find it (e.g. http://localhost:55129/Cars.svc).
So do I need to have my service project running in order to add it?
And would I need to set it up in IIS? Or are people mainly running it from within VS, running the WCF project itself?
Here is the error I get when trying to add that service endpoint:
There was an error downloading http://localhost:55129/Cars.svc/_vti_bin/ListData.svc/$metadata.
The request failed with HTTP status 400: Bad Request.
Metadata contains a reference that cannot be resolved: http://localhost:55129/Cars.svc.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:55129/Events.svc. The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.
If you're using the development web service, it has to be running for you to generate client proxies.
Hosting in IIS is more convenient in this respect as it is always running even if you don't have your solution open.

How do I access a workflow service in silverlight?

I have one worflow service named GetDataWorkflowService.xamlx that I want to use in Silverlight.
When I add a service reference to my application, it gives a message 'This Operation is not supported for the relative URI.' It still adds the reference, however.
When I use the referece:
Servicelient proxy=new ServiceClient();
proxy.GetDataCompleted += (o, a) => Debug.WriteLine("Result is " + a.Result);
proxy.GetDataAsync(123);
I get the following error:
An error occurred while trying to make a request to URI 'http://localhost:1234/GetDataWorkflowService.xamlx'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
I don't understand what's happening.
A few things:
What happens if you use the WCF Test Client to call GetData()? Do you get an error or does that work just fine. If you get an error here concentrate on the server parts.
What happens if you set a service reference from a console application and call your workflow service. Same error or does that work?
Is the workflow service hosted in the same web site as the Silverlight client? If not do you have the cross domain policy files setup correctly.
Assuming the WCF Test Client works. Open up fiddler and compare the request from your Silverlight client with that from the WCF Test Client. What is different?
Enable tracing on the server to see if there are any exceptions or warnings that might provide more insight to what is wrong.
Check your startup project to be sure you are starting a web project and not the Silverlight project. For more details see Troubleshooting Workflow Services / Silverlight on my blog

Silverlight WCF Service to Service calls

Question:
Are there known issues making calls to a service that calls another service from Silverlight?
Scenario:
I have the following 3 projects:
SilverlightClient - Silverlight project with a Button
SilverlightClient.Web - A web application that hosts the SilverlightClient.xap.
BackEnd - A different web application that hosts the FOO Service which does some special backend processing.
I have created a Silverlight WCF-Enabled web service in both SilverlightClient.Web and Backend. These are respectively SilverlightClientService and BackEndService.
From SilverlightClient.Web I add a service reference to BackEndService. I have a test ASPX page that I've written code that calls BackEndService successfully.
From SilverlightClient I add a service reference to SilverlightClient.Web's SilverlightClientService. If my SilverlightClientService returns plain data, such as a string, it works quite well.
The moment, however, that I change SilverlightClientService to call BackEndService, I get the following exception:
HTTP 415 - "The request failed with HTTP status 415: Unsupported Media Type."
I had an issue with 2 services not communicating. We finally figured out that using Cassini (the built in Visual Studio IIS) to host the ListenerService 'BackEnd' was causing the problem. Switching the project to start in a virtual directory of IIS allowed the two to communicate.
I was seeing : An error occurred while receiving the HTTP response to http://localhost:1484/MainListenerService.cs. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. and this error:
The HTTP request was forbidden with client authentication scheme 'Anonymous'.
Are you using basicHttpBinding? Silverlight only supports basicHttpBinding but the default when you create a WCF service is wsHttpBinding. You should change that on your web.config before adding the reference on your Silverlight project. Check out this video from Tim Heuer: http://silverlight.net/learn/videos/all/how-to-consume-wcf-and-aspnet-web-services-in-silverlight/