简体   繁体   中英

WCF service hosting on IIS 6

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM