Tuesday, January 27, 2009

Bad request = MaxReceivedMessageSize exceeded

Continuation from two previous posts on the subject.

I forgot to write about the first reason I got "Bad Request". After tracing the message I found the "real" reason:

“The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.”

The default value of the property MaxReceivedMessageSize on WsHttp binding is 65535 bytes. My message was much bigger than that so after increasing the value everything went well.

Monday, January 19, 2009

Workflow Foundation - Message not delivered

When you write a ExternalDataExchange service in WF you

* decorate an interface with the ExternalDataExchange attribute
* add an instance of the ExternalDataExchange service to the WorkflowRuntime
* add an instance of the implementation of your interface to the ExternalDataExchange service (not the WorklowRuntime)

In your interface you probably have some methods and some events. Events that should communicate with WF must have EventArgs that inherits from ExternalDataExchangeEventArgs.

You will get InnerException of "QueueNotFound" exception if
* events that is not part of communication with WF have EventArgs inheriting from ExternalDataExchangeEventArgs
* no workflow subscribing to the event

Workflow Foundation - Look at InnerException

Last week I ended up in a WF project. I had viewed some code and done a presentation in the subject earlier so my experience was not that high.

The project included a WF monitor, designer and a host running WF services and the actual workflows.

We ran into some problem and I want to share two things so you can find issues faster than we did.

1) Allways subscribe to "workflow terminated" and write excaption message to some log or output window
2) Loop all inner exceptions. The real explanation is often hidden in the last one

Bad request = Validation error

Continuation from previous post.

Solving permission problem I still had "Bad Request", but now the inner exception (and the Event Log) got me a validation error.

My WCF DataContract had a Required=True on a property that did not exist on the incoming message from BizTalk.

HTTP Bad Request can certainly mean a lot of things. Be sure to look in every log.

I recommend to config BizTalk, and the WCF service, to trace WCF-traffic. Use the WCF Config tool and the WCF Trace tool. They are located under "C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin" and called "SvcConfigEditor.exe" and "SvcTraceViewer.exe"

Friday, January 16, 2009

Bad request = Access denied

Consuming services can get you "Bad request" error. The problem can be permissions on the service.

I made a WCF service to be consumed by Biztalk. The service is hosted by IIS and there was no problem running the BizTalk WCF Service Consuming Wizard to create schemas, port types and bindings.

The error came when trying to access the service by posting a request to it. Then I got "400 Bad request".

The problem was related to permissions. I forgot to switch application pool on my web application. After selecting the proper pool, running by correct user, I restarted IIS and everything worked fine.