title: Baffled by SoapFaultClientException using Spring WS, HttpClient, and Exchange WS
body: <p>I am attempting to call the Exchange WS 2010 API with Spring WS + HttpClient.  I get the following error...</p>
  
  <pre><code>Jun/27 11:39:06,825 controller.AjaxCalendarController.[] - Unknown Error
  org.springframework.ws.soap.client.SoapFaultClientException: The request is invalid.
      at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:37)
      at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:774)
      at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:600)
      at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:537)
      at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:384)
      at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:378)
      at org.jasig.portlet.calendar.adapter.ExchangeCalendarAdapter.retrieveExchangeEvents(ExchangeCalendarAdapter.java:171)
      at org.jasig.portlet.calendar.adapter.ExchangeCalendarAdapter.getEvents(ExchangeCalendarAdapter.java:132)
      at org.jasig.portlet.calendar.adapter.CalendarEventsDao.getEvents(CalendarEventsDao.java:74)
      at org.jasig.portlet.calendar.mvc.controller.AjaxCalendarController.getEventList(AjaxCalendarController.java:127)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
      at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:358)
      at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.doHandle(AnnotationMethodHandlerAdapter.java:345)
      at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.handleResource(AnnotationMethodHandlerAdapter.java:293)
      at org.springframework.web.portlet.DispatcherPortlet.doResourceService(DispatcherPortlet.java:825)
      at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:525)
      at org.springframework.web.portlet.FrameworkPortlet.serveResource(FrameworkPortlet.java:477)
      at org.jasig.portal.portlet.container.FilterChainImpl.doFilter(FilterChainImpl.java:212)
      at org.jasig.portal.portlet.container.FilterChainImpl.processFilter(FilterChainImpl.java:84)
      at org.jasig.portal.portlet.container.FilterManagerImpl.processFilter(FilterManagerImpl.java:103)
      at org.apache.pluto.container.driver.PortletServlet.dispatch(PortletServlet.java:350)
      at org.apache.pluto.container.driver.PortletServlet.doGet(PortletServlet.java:261)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
      at org.apache.pluto.driver.container.DefaultPortletInvokerService.invoke(DefaultPortletInvokerService.java:229)
      at org.apache.pluto.driver.container.DefaultPortletInvokerService.serveResource(DefaultPortletInvokerService.java:149)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
      at org.jasig.portal.portlet.dao.jpa.ThreadContextClassLoaderAspect.doThreadContextClassLoaderUpdate(ThreadContextClassLoaderAspect.java:63)
      at sun.reflect.GeneratedMethodAccessor101.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
      at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
      at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy210.serveResource(Unknown Source)
      at org.apache.pluto.container.impl.PortletContainerImpl.doServeResource(PortletContainerImpl.java:203)
      at org.jasig.portal.portlet.rendering.PortletRendererImpl.doServeResource(PortletRendererImpl.java:598)
      at org.jasig.portal.portlet.rendering.worker.PortletResourceExecutionWorker.callInternal(PortletResourceExecutionWorker.java:54)
      at org.jasig.portal.portlet.rendering.worker.PortletResourceExecutionWorker.callInternal(PortletResourceExecutionWorker.java:32)
      at org.jasig.portal.portlet.rendering.worker.PortletExecutionWorker$1.call(PortletExecutionWorker.java:165)
      at org.jasig.portal.portlet.rendering.worker.PortletExecutionCallable.call(PortletExecutionCallable.java:119)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>It doesn't tell me anything about what it thinks is wrong with the request.  :(  On the server-side, both IIS and Exchange merely state that a request came through from me and an HTTP 500 was returned.</p>
  
  <p>Here's is the SOAP envelope (captured from the logs):</p>
  
  <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;SOAP-ENV:Header/&gt;
      &lt;SOAP-ENV:Body&gt;
          &lt;ns2:GetUserAvailabilityRequest xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ns3="http://schemas.microsoft.com/exchange/services/2006/types"&gt;
              &lt;ns3:TimeZone&gt;
                  &lt;ns3:Bias&gt;0&lt;/ns3:Bias&gt;
                  &lt;ns3:StandardTime&gt;
                      &lt;ns3:Bias&gt;0&lt;/ns3:Bias&gt;
                      &lt;ns3:Time&gt;02:00:00&lt;/ns3:Time&gt;
                      &lt;ns3:DayOrder&gt;1&lt;/ns3:DayOrder&gt;
                      &lt;ns3:Month&gt;11&lt;/ns3:Month&gt;
                      &lt;ns3:DayOfWeek&gt;Sunday&lt;/ns3:DayOfWeek&gt;
                  &lt;/ns3:StandardTime&gt;
                  &lt;ns3:DaylightTime&gt;
                      &lt;ns3:Bias&gt;0&lt;/ns3:Bias&gt;
                      &lt;ns3:Time&gt;02:00:00&lt;/ns3:Time&gt;
                      &lt;ns3:DayOrder&gt;1&lt;/ns3:DayOrder&gt;
                      &lt;ns3:Month&gt;3&lt;/ns3:Month&gt;
                      &lt;ns3:DayOfWeek&gt;Sunday&lt;/ns3:DayOfWeek&gt;
                  &lt;/ns3:DaylightTime&gt;
              &lt;/ns3:TimeZone&gt;
              &lt;ns2:MailboxDataArray&gt;
                  &lt;ns3:MailboxData&gt;
                      &lt;ns3:Email&gt;
                          &lt;ns3:Name&gt;Drew Wills&lt;/ns3:Name&gt;
                          &lt;ns3:Address&gt;unicon@stcloudstate.edu&lt;/ns3:Address&gt;
                      &lt;/ns3:Email&gt;
                      &lt;ns3:AttendeeType&gt;Required&lt;/ns3:AttendeeType&gt;
                      &lt;ns3:ExcludeConflicts&gt;false&lt;/ns3:ExcludeConflicts&gt;
                  &lt;/ns3:MailboxData&gt;
              &lt;/ns2:MailboxDataArray&gt;
              &lt;ns3:FreeBusyViewOptions&gt;
                  &lt;ns3:TimeWindow&gt;
                      &lt;ns3:StartTime&gt;2012-06-27T00:00:00.000&lt;/ns3:StartTime&gt;
                      &lt;ns3:EndTime&gt;2012-07-04T00:00:00.000&lt;/ns3:EndTime&gt;
                  &lt;/ns3:TimeWindow&gt;
                  &lt;ns3:MergedFreeBusyIntervalInMinutes&gt;60&lt;/ns3:MergedFreeBusyIntervalInMinutes&gt;
                  &lt;ns3:RequestedView&gt;DetailedMerged&lt;/ns3:RequestedView&gt;
              &lt;/ns3:FreeBusyViewOptions&gt;
          &lt;/ns2:GetUserAvailabilityRequest&gt;
      &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>Here also is some trace logging that shows HTTP headers and so forth...</p>
  
  <pre><code>Jun/27 11:39:06,773 conn.DefaultClientConnection.[] - Sending request: POST /EWS/exchange.asmx HTTP/1.1
  Jun/27 11:39:06,773 http.wire.[] - &gt;&gt; "POST /EWS/exchange.asmx HTTP/1.1[\r][\n]"
  Jun/27 11:39:06,773 http.wire.[] - &gt;&gt; "Accept-Encoding: gzip[\r][\n]"
  Jun/27 11:39:06,773 http.wire.[] - &gt;&gt; "Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2[\r][\n]"
  Jun/27 11:39:06,773 http.wire.[] - &gt;&gt; "SOAPAction: "http://schemas.microsoft.com/exchange/services/2006/messages/GetUserAvailability"[\r][\n]"
  Jun/27 11:39:06,773 http.wire.[] - &gt;&gt; "Content-Type: text/xml; charset=utf-8[\r][\n]"
  Jun/27 11:39:06,773 http.wire.[] - &gt;&gt; "Content-Length: 1362[\r][\n]"
  Jun/27 11:39:06,773 http.wire.[] - &gt;&gt; "Host: mail.stcloudstate.edu[\r][\n]"
  Jun/27 11:39:06,774 http.wire.[] - &gt;&gt; "Connection: Keep-Alive[\r][\n]"
  Jun/27 11:39:06,774 http.wire.[] - &gt;&gt; "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]"
  Jun/27 11:39:06,774 http.wire.[] - &gt;&gt; "Cookie: exchangecookie=49398e25ac5b4b84a19f93d170b3eefa[\r][\n]"
  Jun/27 11:39:06,774 http.wire.[] - &gt;&gt; "Cookie2: $Version=1[\r][\n]"
  Jun/27 11:39:06,774 http.wire.[] - &gt;&gt; "Authorization: NTLM xxx[\r][\n]"
  Jun/27 11:39:06,774 http.wire.[] - &gt;&gt; "[\r][\n]"
  Jun/27 11:39:06,774 http.headers.[] - &gt;&gt; POST /EWS/exchange.asmx HTTP/1.1
  Jun/27 11:39:06,774 http.headers.[] - &gt;&gt; Accept-Encoding: gzip
  Jun/27 11:39:06,774 http.headers.[] - &gt;&gt; Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
  Jun/27 11:39:06,774 http.headers.[] - &gt;&gt; SOAPAction: "http://schemas.microsoft.com/exchange/services/2006/messages/GetUserAvailability"
  Jun/27 11:39:06,774 http.headers.[] - &gt;&gt; Content-Type: text/xml; charset=utf-8
  Jun/27 11:39:06,774 http.headers.[] - &gt;&gt; Content-Length: 1362
  Jun/27 11:39:06,774 http.headers.[] - &gt;&gt; Host: mail.stcloudstate.edu
  Jun/27 11:39:06,774 http.headers.[] - &gt;&gt; Connection: Keep-Alive
  Jun/27 11:39:06,774 http.headers.[] - &gt;&gt; User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
  Jun/27 11:39:06,774 http.headers.[] - &gt;&gt; Cookie: exchangecookie=49398e25ac5b4b84a19f93d170b3eefa
  Jun/27 11:39:06,775 http.headers.[] - &gt;&gt; Cookie2: $Version=1
  Jun/27 11:39:06,775 http.headers.[] - &gt;&gt; Authorization: NTLM xxx
  Jun/27 11:39:06,776 http.wire.[] - &gt;&gt; "&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;SOAP-ENV:Header/&gt;&lt;SOAP-ENV:Body&gt;&lt;ns2:GetUserAvailabilityRequest xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ns3="http://schemas.microsoft.com/exchange/services/2006/types"&gt;&lt;ns3:TimeZone&gt;&lt;ns3:Bias&gt;0&lt;/ns3:Bias&gt;&lt;ns3:StandardTime&gt;&lt;ns3:Bias&gt;0&lt;/ns3:Bias&gt;&lt;ns3:Time&gt;02:00:00&lt;/ns3:Time&gt;&lt;ns3:DayOrder&gt;1&lt;/ns3:DayOrder&gt;&lt;ns3:Month&gt;11&lt;/ns3:Month&gt;&lt;ns3:DayOfWeek&gt;Sunday&lt;/ns3:DayOfWeek&gt;&lt;/ns3:StandardTime&gt;&lt;ns3:DaylightTime&gt;&lt;ns3:Bias&gt;0&lt;/ns3:Bias&gt;&lt;ns3:Time&gt;02:00:00&lt;/ns3:Time&gt;&lt;ns3:DayOrder&gt;1&lt;/ns3:DayOrder&gt;&lt;ns3:Month&gt;3&lt;/ns3:Month&gt;&lt;ns3:DayOfWeek&gt;Sunday&lt;/ns3:DayOfWeek&gt;&lt;/ns3:DaylightTime&gt;&lt;/ns3:TimeZone&gt;&lt;ns2:MailboxDataArray&gt;&lt;ns3:MailboxData&gt;&lt;ns3:Email&gt;&lt;ns3:Name&gt;Drew Wills&lt;/ns3:Name&gt;&lt;ns3:Address&gt;unicon@stcloudstate.edu&lt;/ns3:Address&gt;&lt;/ns3:Email&gt;&lt;ns3:AttendeeType&gt;Required&lt;/ns3:AttendeeType&gt;&lt;ns3:ExcludeConflicts&gt;false&lt;/ns3:ExcludeConflicts&gt;&lt;/ns3:MailboxData&gt;&lt;/ns2:MailboxDataArray&gt;&lt;ns3:FreeBusyViewOptions&gt;&lt;ns3:TimeWindow&gt;&lt;ns3:StartTime&gt;2012-06-27T00:00:00.000&lt;/ns3:StartTime&gt;&lt;ns3:EndTime&gt;2012-07-04T00:00:00.000&lt;/ns3:EndTime&gt;&lt;/ns3:TimeWindow&gt;&lt;ns3:MergedFreeBusyIntervalInMinutes&gt;60&lt;/ns3:MergedFreeBusyIntervalInMinutes&gt;&lt;ns3:RequestedView&gt;DetailedMerged&lt;/ns3:RequestedView&gt;&lt;/ns3:FreeBusyViewOptions&gt;&lt;/ns2:GetUserAvailabilityRequest&gt;&lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt;"
  Jun/27 11:39:06,801 http.wire.[] - &lt;&lt; "HTTP/1.1 500 Internal Server Error[\r][\n]"
  Jun/27 11:39:06,801 http.wire.[] - &lt;&lt; "Cache-Control: private[\r][\n]"
  Jun/27 11:39:06,801 http.wire.[] - &lt;&lt; "Transfer-Encoding: chunked[\r][\n]"
  Jun/27 11:39:06,801 http.wire.[] - &lt;&lt; "Content-Type: text/xml; charset=utf-8[\r][\n]"
  Jun/27 11:39:06,802 http.wire.[] - &lt;&lt; "Server: Microsoft-IIS/7.5[\r][\n]"
  Jun/27 11:39:06,802 http.wire.[] - &lt;&lt; "X-AspNet-Version: 2.0.50727[\r][\n]"
  Jun/27 11:39:06,802 http.wire.[] - &lt;&lt; "Persistent-Auth: true[\r][\n]"
  Jun/27 11:39:06,802 http.wire.[] - &lt;&lt; "X-Powered-By: ASP.NET[\r][\n]"
  Jun/27 11:39:06,802 http.wire.[] - &lt;&lt; "Date: Wed, 27 Jun 2012 18:39:05 GMT[\r][\n]"
  Jun/27 11:39:06,802 http.wire.[] - &lt;&lt; "[\r][\n]"
  Jun/27 11:39:06,802 conn.DefaultClientConnection.[] - Receiving response: HTTP/1.1 500 Internal Server Error
  Jun/27 11:39:06,802 http.headers.[] - &lt;&lt; HTTP/1.1 500 Internal Server Error
  Jun/27 11:39:06,802 http.headers.[] - &lt;&lt; Cache-Control: private
  Jun/27 11:39:06,802 http.headers.[] - &lt;&lt; Transfer-Encoding: chunked
  Jun/27 11:39:06,802 http.headers.[] - &lt;&lt; Content-Type: text/xml; charset=utf-8
  Jun/27 11:39:06,802 http.headers.[] - &lt;&lt; Server: Microsoft-IIS/7.5
  Jun/27 11:39:06,802 http.headers.[] - &lt;&lt; X-AspNet-Version: 2.0.50727
  Jun/27 11:39:06,802 http.headers.[] - &lt;&lt; Persistent-Auth: true
  Jun/27 11:39:06,802 http.headers.[] - &lt;&lt; X-Powered-By: ASP.NET
  Jun/27 11:39:06,802 http.headers.[] - &lt;&lt; Date: Wed, 27 Jun 2012 18:39:05 GMT
  Jun/27 11:39:06,804 exchange.NtlmAuthHttpClient.[] - Connection can be kept alive indefinitely
  Jun/27 11:39:06,808 http.wire.[] - &lt;&lt; "247[\r][\n]"
  Jun/27 11:39:06,808 http.wire.[] - &lt;&lt; "&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;s:Body&gt;&lt;s:Fault&gt;&lt;faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types"&gt;a:ErrorInvalidRequest&lt;/faultcode&gt;&lt;faultstring xml:lang="en-US"&gt;The request is invalid.&lt;/faultstring&gt;&lt;detail&gt;&lt;e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors"&gt;ErrorInvalidRequest&lt;/e:ResponseCode&gt;&lt;e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors"&gt;The request is invalid.&lt;/e:Message&gt;&lt;/detail&gt;&lt;/s:Fault&gt;&lt;/s:Body&gt;&lt;/s:Envelope&gt;"
  Jun/27 11:39:06,808 http.wire.[] - &lt;&lt; "[\r][\n]"
  Jun/27 11:39:06,808 http.wire.[] - &lt;&lt; "0[\r][\n]"
  Jun/27 11:39:06,808 http.wire.[] - &lt;&lt; "[\r][\n]"
  Jun/27 11:39:06,809 tsccm.ThreadSafeClientConnManager.[] - Released connection is reusable.
  </code></pre>
  
  <p>Thank you mightily for any assistance with this thorny issue.</p>