WCF Service Deployment - wcf

I have created an ASP.NET web application that contains a WCF Service. I have successfully tested this application locally. In addition, I can successfully use my WCF service. I then deployed it to my remote IIS 7 web server which has an HTTPS binding setup. I don't know if that makes a difference.
When I attempt to access the svc file in my browser (via something like https://www.mydomain.com/myService.svc), I see the service description page. However, when I attempt to execute my operation through the browser (like https://www.mydomain.com/myService.svc/Test) I get a 404 error. The only thing my "Test" operation does is return "Hello World" as shown here:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
[ServiceBehavior(IncludeExceptionDetailInFaults = false)]
[ServiceContract]
public class MyService
{
[OperationContract]
[WebGet(UriTemplate = "/Test", ResponseFormat = WebMessageFormat.Json)]
public string Test()
{
return "Hello World";
}
}
In an attempt to diagnose the problem further, I created a new ASP.NET web application. In this new application, I attempted to add a new service reference to "https://www.mydomain.com/myService.svc". When I do this, I get a long error message that says:
The document at the url https://www.mydomain.com/myService.svc was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
- Report from 'https://www.mydomain.com/myService.svc' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
- Report from 'DISCO Document' is 'There was an error downloading 'http://computername.com/myService.svc?disco'.'.
- The request failed with HTTP status 502: Fiddler - DNS Lookup Failed.
- Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
Metadata contains a reference that cannot be resolved: 'https://www.mydomain.com/myService.svc'.
There was no endpoint listening at https://www.mydomain.com/myService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.
What am I doing wrong? Thank you!

Ah ha! The problem was I did not have "bindingConfiguration="SSL"" in my configuration on the deployment server. Added that and everything is peachy.
Thank s for your help!

Related

Error on adding a service reference to use web-centric WCF service?

I am trying to follow a textbook learning how to create a web-sentric WCF service project. I created the service, and see the corresponding folder under Default Web Site on IIS. I can even browse the folder (localhost/EmployeeService/) and see the contents in the browser. Now I want to make a client, i.e. a simple Console application. When I am trying to add a Service Reference, after I enter the address, I get an error:
There was an error downloading 'http://localhost/EmployeeService/$metadata'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://localhost/EmployeeService/'.
The remote server returned an unexpected response: (405) Method Not Allowed.
The remote server returned an error: (405) Method Not Allowed.
Could you please explain? I saw some questions about the same error, but could not find a solution for myself.
Thanks.
In order to invoke the service, you must point at the service file. Otherwise the web server doesn't know what you're trying to do.
Add the .svc file to your URL to do that, so http://localhost/EmployeeService/YourService.svc.
You can also have it fileless, see How can I host a WCF service without an SVC file in IIS.

WCF POST method doesn't get called

I've created a WCF REST service and initially used .Net Framework version 4. The service has two methods, one returns a plain string with the service status. The second allows a file to be uploaded. Both methods were working fine.
I was asked to see if the project could be moved back to only depend on .Net Framework 3.5 instead of version 4. I changed some references, and it built ok, and when I use the existing C++ client I can use the GetStatus method fine. However, now when a file gets uploaded, the client sees successful return codes to all methods, but, when I set a breakpoint at the start of WCF service's FileUpload method, it never gets executed. The file doesn't gets uploaded, it just disappears into the ether.
[ServiceContract]
internal interface IMyWebService
{
[OperationContract]
[WebGet(UriTemplate = "/Status", BodyStyle=WebMessageBodyStyle.Bare)]
Stream GetStatus();
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/FileUpload/{fileName}")]
Stream FileUpload(string fileName, Stream fileStream);
}
I've tried to use the WFetch tool as an alternative client. When I call the FileUpload method, I get this log:
started....WWWConnect::Close("localhost","80")\nclosed source port: 15800\r\n
WWWConnect::Connect("localhost","80")\nIP = "[::1]:80"\nsource port: 15866\r\n
REQUEST: **************\nPOST http://myMachine/MyService/FileUpload/hello.txt HTTP/1.1\r\n
Host: localhost\r\n
Accept: */*\r\n
Content-Length:11\r\n
\r\n
hello thereRESPONSE: **************\nHTTP/1.1 415 Missing Content Type\r\n
Content-Length: 0\r\n
Server: Microsoft-HTTPAPI/2.0\r\n
Date: Thu, 22 Sep 2011 13:26:09 GMT\r\n
\r\n
finished.
Could anybody give me any pointers for how I can diagnose this issue? I'm having trouble seeing where to start because no breakpoints get hit, and there are no error codes to investigate.
The WCF service must be doing something, because if I stop it, the client then fails to upload files, I just can't understand why execution never gets to the method that implements the POST operation.
Hmm, when using WFetch, even if I misspell the name of the method, it still seems to succeed with no error.
Thanks.
I'd start troubleshooting with the original 4.0 version of the service and a C# WCF-based test client to verify the service code will actually upload a file successfully. You could use the code in this Technet article for developing the test client.
Next, use your C++ client against the 4.0 service to verify your client will successfully send a file. Lastly, set the service back to 3.5 and see if it still works. To log messages the service is receiving for troubleshooting, look at this MSDN post to configure the built-WCF message logging capability.

WCF Server Error. The content type text/html of the response message does not match the content type of the binding

I've got a WCF Service, which calls a webservice, running on my development IIS server (IIS 7). I've added it as a service reference to a C# Website Project and it adds fine.
However, when I try to call any of the service contracts, I get the following error:
The content type text/html
of the response message does not match
the content type of the binding
(text/xml; charset=utf-8). If using a
custom encoder, be sure that the
IsContentTypeSupported method is
implemented properly. The first 1024
bytes of the response were:
'Blocked Web
Page
thanks in advance
BB
The error message says it clearly: you're getting back an HTML page instead of your service response. Looking at the fragment of that page listed in the error message, you're probably not authroized to use that service.
Try to connect to the service URL in a browser - you should probably see a page explaining that you're not allowed to access the page. Most likely, this is a permissions issue.
You need to configure WCF Tracing and find out what's happening on the server side.

The remote server returned an error : 400 badrequest in WCF

In our project, we are calling the .svc file directly from asp.net web page and I receive the error "The remoter server returned an error:(400) bad request.
Our project architecture is, we are using .svc file in our web application and the .cs file for the svc in writter in another class library project. From aspx, we are calling the WCF service directly without adding reference or anything. I cannot change the concept, because it is our standard. I'm able to add service reference and call those methods, but I wanted to call the method directly from .svc url.
I'm pissed off for 2 days and could not resolve the error. We are using HttpWebRequest to get the response from the service. Basically, the service will take Data Transfer Object(DTO) as input and returns the same(DTO) as output with only one value.
Check the following code:
HttpStatusCode statusCode = HttpHelper.PostXmlRequestValue(requestXMLInput,
string.Format("http://{0}/{1}/MySample.svc/webhttp/MyMethodName",
Request.ServerVariable["HTTP_HOST"], Request.ApplicationPath);
The same code works in one machine but not in the other. I have checked the configuration and everything is same, but still I receive the same error.
When I use the .svc url in my machine, it works, but gives a message "Method not allowed". When I checked the same url in the working machine, I got the same message.. I believe there is some simple thing I'm missing out. I couldn't find, as I'm new to WCF.
When using HttpWebRequest the "Method not allowed" error is for example that you are sending a Http GET, when the service expects a Http POST.
HttpWebRequest is a REST based configuration, this limits the complexity of the DTO's that you can send.

not sure if this is my mistake ~~ vs2010 Add Service Reference fails

https://tbe.taleo.net/MANAGER/dispatcher/servlet/rpcrouter
the above is from Taleo's API guide.
I'm trying to create a WCF Client
(e.g.: " Creating Your First WCF Client"
http://channel9.msdn.com/shows/Endpoint/Endpoint-Screencasts-Creating-Your-First-WCF-Client/ )
The tbe.taleo... link is from Taleo's API documentation.
Likely my understanding is flawed. My assumption is that when the
link from Taleo is entered into the vs2010 "Add Service Reference"
dialog and GO is clicked, then vs2010 should retrieve
a proper WSDL/SOAP envelope back from the Taleo link.
That does not happen; instead an error occurs.
Fiddler2 (http://fiddler2.com) displays the status code 500
"HTTP/1.1 500 Internal Server Error". [FULL DETAILS BELOW]
"WcfTestClient.exe" gives a similar error: [WcfTestClient DETAILS BELOW]
QUESTION: is it me, or is the Taleo link flawed?
Thank you,
Gerry
[FULL DETAILS "Add Service Reference"]
The HTML document does not contain Web service discovery information.
Metadata contains a reference that cannot be resolved: 'https://tbe.taleo.net/MANAGER/dispatcher/servlet/rpcrouter'.
The content type text/xml;charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 544 bytes of the response were: '
SOAP-ENV:Protocol
Unsupported content type "application/soap+xml; charset=utf-8", must be: "text/xml".
/MANAGER/dispatcher/servlet/rpcrouter
'.
The remote server returned an error: (500) Internal Server Error.
If the service is defined in the current solution, try building the solution and adding the service reference again.
[WcfTestClient DETAILS]
Error: Cannot obtain Metadata from https://tbe.taleo.net/MANAGER/dispatcher/servlet/rpcrouter If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: https://tbe.taleo.net/MANAGER/dispatcher/servlet/rpcrouter Metadata contains a reference that cannot be resolved: 'https://tbe.taleo.net/MANAGER/dispatcher/servlet/rpcrouter'. The content type text/xml;charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 544 bytes of the response were: 'SOAP-ENV:ProtocolUnsupported content type "application/soap+xml; charset=utf-8", must be: "text/xml"./MANAGER/dispatcher/servlet/rpcrouter'. The remote server returned an error: (500) Internal Server Error.HTTP GET Error URI: https://tbe.taleo.net/MANAGER/dispatcher/servlet/rpcrouter The HTML document does not contain Web service discovery information.
Browsing to the Taleo link, I get
SOAP RPC Router
Sorry, I don't speak via HTTP GET- you
have to use HTTP POST to talk to me.
My suspicion is that both Visual Studio and Fiddler do an HTTP GET to retrieve the WSDL (a description of the Web Service). Instead, they're getting an HTML error message.
Adding "?WSDL" to the URL didn't help. So I'd say the Taleo link is not intended to be used in this manner, but instead is designed for SOAP RPC.
Sadly, I can only blame myself. I watched the excellent free Pluralsight videos.
I tried to sort it out from Taleo's documentation, Google, msdn, et cetera.
I should have used this:
http://tbe.taleo.net/wsdl/DispatcherAPI.wsdl
from here:
http://tbe.taleo.net/products/TBE_API_Guide.pdf from
http://www.taleo.com/solutions/taleo-business-edition-web-integration-api
Thanks to all who gave some thought to this issue.
g.
You are not to be blamed. The Taleo documentation is a bit confusing. Especially with respect to the URL to be used.
For a detailed description check out Taleo Integration in Drupal