Https WCF webservice giving Http 400 error while calling method from browser - wcf

I have created a wcf web service. When i run it for http it works fine and gives result in wcftestclient as well as browser.
But when i test for https by changing it fot https it gives result in wcftestclient but when i try to call method from url by passing parameters. i receive error.
HTTP 400 error
It’s not you, it’s this link (it appears to be broken).
I have changed configuration file for https. It is working in wcftestclient but not in browser. it gives wsdl file but error for method calling.
I call method as
https://my-pc/Service.svc/LogIn?a;a

Quick way is Goto project properties of your WCF Service Project in Visual studio, open Web tab/page and make sure IIS web server is selected and IIS Express not selected mention your web address like https://localhost/WcfService1 and if virtual directory is not created then Click on "Create Virtual Directory Button", visual studio will create with required SSL settings for you.
To verify open Internet Information Manager(inetmgr), select service virtual directory/website and verify binding in Actions pane on the right hand side.
It should have two browse links under Manage Application heading one for HTTP and one for HTTPS.
Hope this helps.

Related

Open .SVC in web browser

I have been given a URI for a WCF web service (something like http://some_uri:portnumber/someservice/service.svc) but I cannot open it via a web browser or postman. I tried to open it with cURL but nothing happened either. Is there a certain wat to open .svc file on ubuntu?
You can open this URI by web browser:
You can also open this URI through postman:
We can use svcutil to generate proxy classes to call the service. Please make sure that your WCF service is successfully deployed to IIS.
Feel free to let me know if the problem persists.

Referencing a Published WCF Service

I have followed "Walkthrough: Creating and Accessing WCF Services" from http://msdn.microsoft.com/en-us/library/bb386386.aspx to create a WCF Service Library. I tested it in WCF Test Client. Then in another desktop application (let's call it A) that eventually I would like to use this WCF I added the Service Reference that WCF Test Client gives
http://localhost:8733/...
and that worked too.
Now, I am in the process of publishing and using the published version's service reference. Here is what I did, I published the WCF Service Library by
right-clicking the solution
Choosing Publish
clicking ...
Choosing File System and typing
\mywebaddress.example.com\wwwroot\myWCFService
Looks like the publish is successful, because by navigating to
\\mywebaddress.example.com\wwwroot\myWCFService
in a file browser, I see that Web.config, .svc and bin folder are created.
Now, I am trying to refer to this published version from my desktop application A. I am not certain what options I'm supposed to choose
Here is what I have tried:
Choose Add Service Reference in the desktop application A,
I tried
\mywebaddress.example.com\wwwroot\myWCFService
in the Address field of Add Service Reference, Pressed Go and received the error An error (Details) occurred while attempting to find services at
\\mywebaddress.example.com\wwwroot\myWCFService.
When clicking on Details, I get There was an error downloading
\\mywebaddress.example.com\wwwroot\myWCFService
Access to the path
\\mywebaddress.example.com\wwwroot\myWCFService
is denied.
If the service is defined in the current solution, try building the solution and adding the service reference again.
Alternatively, I tried Advanced option from Add Service Reference and from there Add Web Reference... and in the URL field typed
http://www.example.com/myWCFService/
then when pressing the arrow button I get 401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied. and in the Web services found at this URL: Value cannot be null. Parameter name: discoveryError & mexError.
Th latter error was when in the IIS setting I had Anonymous Authentication Disabled. After enabling Anonymous Authentication the error becomes:
403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.
Web services found at this URL: There was an error downloading
http://www.example.com/wcfservice/_vti_bin/ListData.svc/$metadata
The request failed with HTTP status 404: Not Found.
When I just now published a WCF Service Library project with Visual Studio 2013, I was offered the options for file system, Local IIS, and FTP Site. When I choose "Local IIS", it shows me both IIS Express and my local full IIS.
I just published to IIS by selecting "Default Web Site" and clicking the "Create Web Application" button in the tooolbar. I named the application, clicked "Open", then clicked "Publish" on the main publish dialog.
This published a bin folder with the service DLL and other libraries it needed, a web.config, and a .svc file. I was able to browse to the .svc file with no problem. I was even able to add it as a service reference to another project.
If you are always going to host your services in IIS, and if you don't need to keep a clean separation of layers (perhaps you're only writing a few, simple services), then I recommend you use the "WCF Service Application" template instead. This creates a Web project in which to host the services, as well as the .svc and .cs files necessary for the services themselves. That's more like the only option that was available for ASMX web services.

Hosting WCF service in IIS

I am trying to host the service in IIS but I get Page Not found error.
Here is what I did to host in IIS
Created a WCF Service application (BillingService)
I have two classes called IBillSrv.cs (as Base) and BillSrvc.cs
Added a new WCFService website (BillSrvcSite) to the solution and added a reference to the above mentioned (BillingService).
In IIS created a new Virtual site and mapped it to BillSrvSite
Opened the Web.Config and changed the endpoint contract to IBillSrv
When I run it works fine in the WCF test client.
but when i paste the below url in IE I get page not found.
http://localhost/BillingService/BillSrvc/
I am using C# 2008
Can someone please advise what is missing or where I am going wrong?
This has nothing to do with persistence. An interface member like ParseTestQues can only be implicitly implemented by a public method. Simply make ParseTestQues be public.
Isn't your service endpoint named something like "BillSrvc.svc"? Try typing http://localhost/BillingService/BillSrvc/BillSrvc.svc into the browser and see what happens.

WCF Service calling another WCF service fails with web error 400 Bad Request

We have a web service that is called when user clicks save button on web form. The 'save' web service then makes a call into another web service (different machine). The call always fails and as far as I can tell does not even attempt to cross the network because the Fiddler traffic is empty. This problem only occurs when we call the second web service from the first web service. If we call the second web service straight from the client or on page load, it works. We are using WebHTTPBinding with REST type services.
I used the WCF trace to come up with the error 'Envelope Version 'EnvelopeNone (http://schemas.microsoft.com/ws/2005/05/envelope/none)' does not support adding Message Headers.', but I don't know how to resolve it.
Any suggestions?
Possible fixes:
Check #ServiceHost directive( in
. svc file) is set to
"WebServiceHostFactory" source
WebHttpBeahvior element is added in
the endpoint behavior source
Put ORDER information in the XML
schema Class source
Check that your Data Transfer objects are
serrializable source
Check if Skype installed and make sure it
doesn't overtake the port
source
Remove SOAP message header (it is not supported for REST
WCF) source

Silverlight looking at wrong url for clientaccesspolicy file

i have a silverlight app connected to a webservice over https.
The webservice is hosted on mydomain.com (not localhost).
When i run the silverlight, it makes https calls to webservice on mydomain.com, but also tries to access "http://localhost/clientaccesspolicy.xml" and fails obviously. Why is my SL app looking for cal.xml in localhost? why is it not looking for cal.xml in the mydomain.com?
Appreciate your thoughts.
Thanks!
"Before allowing a connection to a network resource, the Silverlight runtime will try to download a security policy file from the domain that hosts the network resource. There are two different methods used to download the security policy that depend on whether the connection request was from a WebClient or HTTP class or whether the connection request was from sockets.
If the connection request was from a WebClient or an HTTP class to a cross-domain site, the Silverlight runtime tries to download the security policy file using the HTTP protocol. The Silverlight runtime first tries to download a Silverlight policy file with a name of "clientaccesspolicy.xml" at the root of the requested target domain using the HTTP protocol.
If the "clientaccesspolicy.xml" is either not found (the web request returns a 404 status code), returned with an unexpected mime-type, is not valid XML, or has an invalid root node, then the Silverlight runtime will issue a request for a for the Flash policy file with a name of "crossdomain.xml" at the root of the requested target domain, using the HTTP protocol."
http://msdn.microsoft.com/en-us/library/cc645032%28VS.95%29.aspx
What does the address look like inside your SL application?
Is the address coming from the ServiceReference.ClientConfig file? If so, make sure that it has a mydomain.com and not a localhost address there.