0

I have an .net 4.0 WCF REST service, which locally runs perfectly fine on Windows 7 IIS 7, but when I try to deploy it on my QA server, which runs Windows Server 2003 and has IIS 6, I start getting Bad Request errors. I've already tried this solution, but it does not work for me. It seems that XML I'm sending to server is not being deserialized, I'm using XmlSerializer. Any ideas?

EDIT: Using Fiddler I've got exception details:

    Request Error
      The server encountered an error processing the request. The exception message is 'There is an error in XML document (4, 354066).'. See server logs for more details. The exception stack trace is: </p>
      at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)
   at System.ServiceModel.Dispatcher.UnwrappedTypesXmlSerializerManager.XmlSerializerXmlObjectSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)
   at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.ReadObject(Message message)
   at System.ServiceModel.Dispatcher.SingleBodyParameterMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.CompositeDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

xmlvalidation.com tells me my XML is correct, also I'm getting correct response with the same XML on my local IIS

Solution: here

Community
  • 1
  • 1
insomnium_
  • 1,800
  • 4
  • 23
  • 39
  • Are you getting the errors when trying to hit the WCF service from the browser, from the WCF test client, or from within your own code making calls to the WCF service? Also, do you mind posting some exception details to show more info about the bad request. – Ayo I Jul 08 '13 at 07:55
  • I have no errors when I hit service address in browser, but when I try to invoke POST method from my c# app, I get "Server response: Bad request" – insomnium_ Jul 08 '13 at 08:07
  • Did you set application pool to 4.0 for your virtaul directory in IIS6? – Chirag Vidani Jul 08 '13 at 08:13
  • How to do that on IIS 6? I've performed right click on Virtual Directory -> properties -> ASP.NET - > version = 4.0 – insomnium_ Jul 08 '13 at 08:18
  • Refer this [link](https://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/2a231dcb-d786-4b6d-b3ba-bda04061a5e7.mspx?mfr=true) – Chirag Vidani Jul 08 '13 at 08:19
  • The link does not have any info regarding .NET 4.0 applying to app pool in IIS 6 – insomnium_ Jul 08 '13 at 08:25
  • Yes, that link was describing issue I've struggled with and helped me to solve it. – insomnium_ Jul 10 '13 at 08:59

2 Answers2

0

There are 2 possibilities:

  • It could be a version difference. The xml that you are sending to the service is the same. But the C# dto class on IIS 6 is different, therefore the deserialization error.
  • You have used some datatypes (for example enums) that are only supported in WCF using .net framework 4.

Try this:

  • Add a new method to the contact that accepts a string and returns a string.
  • Check that that works on both macines
  • Then gradually increase the complexity of the method untill it matches your actual method, testing after each change.
Shiraz Bhaiji
  • 64,065
  • 34
  • 143
  • 252
  • I've installed .net 4.0 on both computers, so, probably, the second possibility could be excluded. Could you explain what do you mean with the first possibility? – insomnium_ Jul 08 '13 at 09:39
  • for the first possibility check that the timestamp on the dll's on both machines are the same. On the second one just because .net 4 is installed does not mean that it is being used. – Shiraz Bhaiji Jul 08 '13 at 09:54
  • Code is the same, libraries are the same. I totally don't know what to do now. – insomnium_ Jul 08 '13 at 11:16
0

The issue I was struggling with was not set max length of message's single text field. I assume, that if the value is 0, IIS takes some kind of default value, which for IIS 7 is bigger than IIS 6 and luckily enough for my XML message. Please, reference this link.

Community
  • 1
  • 1
insomnium_
  • 1,800
  • 4
  • 23
  • 39