Friday, August 20, 2010

WCF - The document format is not recognized (the content type is 'text/html; charset=UTF-8').

Well, I faced a strange issue today while trying to deploy my WCF Service on a server.

Everything seemed to work perfectly, and I can even see the service on my browser, until when I tried to test this through a "wcftestclient" I encountered this error message.



Error: Cannot obtain Metadata from http://192.168.0.15:8090/service.svc

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: http://192.168.0.15:8090/service.svc  

Metadata contains a reference that cannot be resolved: 'http://192.168.0.15:8090/service.svc'.   

There was no endpoint listening at http://192.168.0.15:8090/service.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.HTTP GET Error    URI: http://192.168.0.15:8090/service.svc   

The document at the url http://192.168.0.15:8090/service.svc was not recognized as a known document type.The error message from each known type may help

you fix the problem:-

 Report from 'http://192.168.0.15:8090/service.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://myComputer.mydomain.local:8090/Service.svc?disco'.'.  -

The remote name could not be resolved: 'myComputer.mydomain.local'- Report from 'WSDL Document' is 'The document format is not recognized (the content type is

'text/html; charset=UTF-8').'.-

Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

I could not figure out what the issue was. It worked perfectly on other machine and it was basically the copy from the other server. But I was getting the above error.

After trying for couple of ours from my machine connecting to this server. I decide I will install free version of "WCFStorm-Lite" on the server and see I can download the meta-data on the 'wcftestclient'. And guess, what I was able to do it, which puzzled me more.
Why would it run on the local mahince but not over the network??

Well, the answer my friend is in the question itself. Some the DNS address of the server I was trying to connect to wasn't registered by our IT department.
Hence, what was happening was whenever I try to connect to the ip-address, to get the meta-data it was actually trying to connect to "myComputer.myDomain.local" but since "myComputer.myDomain.local" was configured for any ip-address it was getting lost.

Hence, what I had to do was to get my "IT Department" to register "myComputer.myDomain.local" for the ip-address "192.168.0.15". Even tested this my trying to "ping myComputer.myDomain.local" which resolved to 192.168.0.15.

Finally, tested the WCFTestClient and it worked like a charm.

If any of you out there are having the same issue try the solution above, it may fix your issue as well.
Good Luck.

No comments:

Post a Comment