I'm helping build a site in CQ where I have a requirement to allow authors to create forms with the standard form components that will POST their data to an external system. I discovered the documentation detailing how to create custom form actions, and I've created a forward.jsp where I'm simply trying to forward the request to the external system. It seems however, that CQ wants to interpret the URL as an internal path and gives me an error. I didn't see anything in the javadoc or documentation that would lead me to what I want. I'm afraid that I may just end up having to create a servlet in CQ, forward to that, and then post to the external site in that servlet. Has anyone here had any luck doing what I want or know if it's even possible?
forward.jsp:
<%# page session="false" %>
<%# page import="com.day.cq.wcm.foundation.forms.FormsHelper" %>
<%# taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %>
<sling:defineObjects/>
<%
FormsHelper.setForwardPath(slingRequest, "http://localhost:8080/rest/foo", true);
%>
Exception I'm getting:
17.06.2014 16:22:31.475 *WARN* [0:0:0:0:0:0:0:1 [1403047349971] POST /content/aau/en/form-test.html HTTP/1.1] com.day.cq.security.impl.CQUserManagerImpl Could not resolve Authorizable: failure accessing Repository: Invalid path:/http://localhost:8080/rest/foo
17.06.2014 16:22:31.476 *ERROR* [0:0:0:0:0:0:0:1 [1403047349971] POST /content/aau/en/form-test.html HTTP/1.1] org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception during response processing. javax.jcr.RepositoryException: Incorrect workspace. Expecting /http. Received crx.default
at org.apache.sling.servlets.post.AbstractPostOperation.removeAndValidateWorkspace(AbstractPostOperation.java:222)
at org.apache.sling.servlets.post.AbstractPostOperation.run(AbstractPostOperation.java:78)
at org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:202)
at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:148)
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:344)
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:375)
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:508)
at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:45)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:146)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at com.day.cq.wcm.core.impl.WCMComponentFilter.filterRootInclude(WCMComponentFilter.java:356)
at com.day.cq.wcm.core.impl.WCMComponentFilter.doFilter(WCMComponentFilter.java:168)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at com.day.cq.personalization.impl.TargetComponentFilter.doFilter(TargetComponentFilter.java:96)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:254)
at org.apache.sling.engine.impl.SlingRequestProcessorImpl.dispatchRequest(SlingRequestProcessorImpl.java:294)
at org.apache.sling.engine.impl.request.SlingRequestDispatcher.dispatch(SlingRequestDispatcher.java:216)
at org.apache.sling.engine.impl.request.SlingRequestDispatcher.forward(SlingRequestDispatcher.java:144)
at com.day.cq.wcm.core.impl.WCMComponentFilter$ForwardRequestDispatcher.forward(WCMComponentFilter.java:417)
at com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet.doPost(FormsHandlingServlet.java:140)
at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:148)
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:344)
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:375)
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:508)
at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:45)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilterWithErrorHandling(WCMDebugFilter.java:182)
at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:149)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at com.day.cq.wcm.core.impl.WCMComponentFilter.filterRootInclude(WCMComponentFilter.java:356)
at com.day.cq.wcm.core.impl.WCMComponentFilter.doFilter(WCMComponentFilter.java:168)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at com.day.cq.personalization.impl.TargetComponentFilter.doFilter(TargetComponentFilter.java:96)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:254)
at org.apache.sling.engine.impl.SlingRequestProcessorImpl.dispatchRequest(SlingRequestProcessorImpl.java:294)
at org.apache.sling.engine.impl.request.SlingRequestDispatcher.dispatch(SlingRequestDispatcher.java:216)
at org.apache.sling.engine.impl.request.SlingRequestDispatcher.forward(SlingRequestDispatcher.java:144)
at com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet.doFilter(FormsHandlingServlet.java:215)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at com.day.cq.theme.impl.ThemeResolverFilter.doFilter(ThemeResolverFilter.java:76)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at com.adobe.granite.optout.impl.OptOutFilter.doFilter(OptOutFilter.java:74)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at com.day.cq.wcm.core.impl.WCMRequestFilter.doFilter(WCMRequestFilter.java:90)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at com.adobe.cq.history.impl.HistoryRequestFilter.doFilter(HistoryRequestFilter.java:107)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at com.day.cq.wcm.designimporter.CanvasPageDeleteRequestFilter.doFilter(CanvasPageDeleteRequestFilter.java:88)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at org.apache.sling.rewriter.impl.RewriterFilter.doFilter(RewriterFilter.java:83)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at org.apache.sling.i18n.impl.I18NFilter.doFilter(I18NFilter.java:127)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at org.apache.sling.bgservlets.impl.BackgroundServletStarterFilter.doFilter(BackgroundServletStarterFilter.java:135)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:151)
at org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:206)
at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at org.apache.sling.i18n.impl.I18NFilter.doFilter(I18NFilter.java:127)
at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at org.apache.felix.http.sslfilter.internal.SslFilter.doFilter(SslFilter.java:55)
at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at com.adobe.granite.license.impl.LicenseCheckFilter.doFilter(LicenseCheckFilter.java:179)
at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at org.apache.sling.security.impl.ReferrerFilter.doFilter(ReferrerFilter.java:263)
at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at org.apache.sling.engine.impl.log.RequestLoggerFilter.doFilter(RequestLoggerFilter.java:75)
at org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
at org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
at org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at com.day.j2ee.servletengine.ServletRuntimeEnvironment.service(ServletRuntimeEnvironment.java:250)
at com.day.j2ee.servletengine.RequestDispatcherImpl.doFilter(RequestDispatcherImpl.java:321)
at com.day.j2ee.servletengine.RequestDispatcherImpl.service(RequestDispatcherImpl.java:340)
at com.day.j2ee.servletengine.RequestDispatcherImpl.service(RequestDispatcherImpl.java:383)
at com.day.j2ee.servletengine.ServletHandlerImpl.process(ServletHandlerImpl.java:335)
at com.day.j2ee.servletengine.HttpListener$Worker.run(HttpListener.java:644)
at java.lang.Thread.run(Thread.java:722)
Method FormsHelper.setForwardPath can only be used to forward request to a different servlet on the same CQ instance. That's the purpose of the forward method and you can't use it to make a request to an external server. This page describes the difference between forward and redirect. Redirect can't force the browser to send a POST, so it doesn't solve the problem as well.
If you want to create a standard CQ form that POSTs to an external server, then the external request should be done server side. Create a CQ servlet that handles the form request and uses HttpClient library to send POST to the external site.
CQ 5.6.1 contains commons-httpclient 3.1
If CQ doesn't need to know about the form data at all you could just set the action on the form to be the external URL. Or, if you want to keep the user on your site, you could submit the form data to the external site via AJAX. Either way you would avoid having to redirect the request to the external site on the server side.
Related
I have an old webservice application that always worked well. Suddenly, it stopped working and returns this error. I neither develop applications anymore, for years. I'm out of date.
Can anybody help me to solve this?
AxisFault
faultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode:
faultString: (301)Moved Permanently
faultActor:
faultNode:
faultDetail:
{}:return code: 301
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
{http://xml.apache.org/axis/}HttpErrorCode:301
(301)Moved Permanently
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at MRCS.ServiceANASoapStub.dadosHidrometeorologicos(ServiceANASoapStub.java:631)
at MRCS.ServiceANASoapProxy.dadosHidrometeorologicos(ServiceANASoapProxy.java:50)
at persistence.ConsultaPersisteTelemetrica._getDadosWebService(ConsultaPersisteTelemetrica.java:174)
at persistence.ConsultaPersisteTelemetrica._persisteTelemetrica(ConsultaPersisteTelemetrica.java:100)
at persistence.ConsultaPersisteTelemetrica.execute(ConsultaPersisteTelemetrica.java:42)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
You could intercept such HTTP 301 codes and follow the redirects in your code. However, since you're no longer developing, the easiest way to fix this is to change the URL from http://xml.apache.org/axis/ to the new one that it redirects to, which is http://axis.apache.org/axis/.
I'm trying to send SOAP envelope with standard mule HTTP Request and I'm having trouble with setting Media-Type of an outbound request. The webservice expects "application/soap+xml", but setting 'Content-Type: application/soap+xml' header in POST Request or setting mime-type to payload doesn't seem to work. I keep getting error 415 - unsupported media type. Does anybody have any idea what can I do to resolve this issue? My XML code so far (I've changed names and addresses, the idea stays the same):
<flow name="get-report">
<http:listener config-ref="asdf-httpListenerConfig" path="/" doc:name="HTTP"/>
<custom-transformer encoding="UTF-8" mimeType="application/soap+xml" class="Authorization" doc:name="Java"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<http:request config-ref="HTTP_Request_Configuration" path="path.svc" method="POST" doc:name="HTTP">
<http:request-builder>
<http:header headerName="Content-Type" value="application/soap+xml"/>
<http:header headerName="action" value="someAction"/>
<http:header headerName="host" value="someHost"/>
</http:request-builder>
</http:request>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
The 'Authorization' transformer isn't really relevant, right now I just hardcode entire envelope and return it.
Also, POST'ing an envelope via soapUI with the same addresses, content type and media-type works fine.
Setting the header in the http:request should definitely set the Content-Type header, so i would suggest this is not the issue. Though it is dependant on the API implementation, 415 Unsupported Media Type can be caused by the requests Content-Type, Content-Encoding or by inspecting the data directly. Perhaps it could be caused by the XML structure.
Asked to evaluate buying Mulesoft - and produce demo that connects to facebook. Am following the two samples here:
https://github.com/mulesoft/facebook-connector/blob/master/doc/sample.md
and
http://blogs.mulesoft.com/mule-school-integration-with-social-media-part-ii-%E2%80%93-facebook/
Ran into a problem with the first sample - it wouldn't compile because the endpoint for the http connector was the same as the facebook connector. I did some research and made some changes, but I now get the error below and can't find anyone else that experienced the same:
Unable to fetch access token. Message payload is of type: NullPayload - this is on the callback page. Has anyone experienced this?
Here is my code:
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8099" doc:name="HTTP Listener Configuration"/>
<facebook:config-with-oauth name="Facebook-config" consumerKey="..." consumerSecret="..." scope="user_photos" doc:name="Facebook">
<facebook:oauth-callback-config domain="localhost" localPort="8099" remotePort="8099" path="callback"/>
</facebook:config-with-oauth>
<http:listener-config name="HTTP_Listener_Configuration1" host="localhost" port="8094" doc:name="HTTP Listener Configuration"/>
<flow name="Authorize">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<facebook:authorize config-ref="Facebook-config" doc:name="Facebook"/>
<set-session-variable variableName="accessTokenID" value="#[flowVars['OAuthAccessTokenId']]" doc:name="Save Access Token"/>
<flow-ref name="PhotoDownload" doc:name="Call Photo Download"/>
</flow>
<flow name="PhotoDownload">
<http:listener config-ref="HTTP_Listener_Configuration1" path="/" doc:name="HTTP"/>
<not-filter doc:name="Not">
<wildcard-filter pattern="/favicon.ico" caseSensitive="false"/>
</not-filter>
<facebook:get-user-picture config-ref="Facebook-config" user="me" accessTokenId="#[sessionVars['accessTokenId']]" doc:name="Get Profile Picture"/>
<file:outbound-endpoint path="c:\temp" outputPattern="profilepic.jpg" responseTimeout="10000" doc:name="Save The Picture "/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
Here is the stack trace:
ERROR 2015-06-10 13:47:07,731 [[internalfacebook].HTTP_Listener_Configuration.worker.01] org mule exception DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Unable to fetch access token. Message payload is of type: NullPayload
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. unable to find valid certification path to requested target (sun.security.provider.certpath.SunCertPathBuilderException)
sun.security.provider.certpath SunCertPathBuilder:-1 (null)
2. PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target (sun.security.validator ValidatorException)
sun.security.validator PKIXValidator:-1 (null)
3. sun.security.validator ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target (javax net ssl SSLHandshakeException)
sun security ssl Alerts:-1 ( java.sun com/j2ee/sdk_1.3/techdocs/api/javax/net/ssl/SSLHandshakeException html)
4. Error found while consuming http resource at https(colonslashslash) graph facebook com/oauth/access_token (java.lang.RuntimeException)
org.mule security oauth util HttpUtilImpl:93 (null)
5. Unable to fetch access token. Message payload is of type: NullPayload (org mule api MessagingException)
org.mule.security.oauth.processor.OAuth2FetchAccessTokenMessageProcessor:95 ( wwwmulesoftrog docs site current3 apidocs org mule api MessagingException html)
--------------------------------------------------------------------------------
Root Exception stack trace:
sun.security.provider certpath SunCertPathBuilderException: unable to find valid certification path to requested target
at sun security provider certpath SunCertPathBuilder engineBuild(Unknown Source)
at java.security cert CertPathBuilder build(Unknown Source)
at sun.security validator PKIXValidator doBuild(Unknown Source)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
INFO 2015-06-10 13:47:08,183 [[internalfacebook].HTTP_Listener_Configuration.worker.01] org mule module http internal listener HttpListenerRegistry: No listener found for request: (GET)/favicon ico
INFO 2015-06-10 13:47:08,184 [[internalfacebook].HTTP_Listener_Configuration.worker.01] org mule module http internal listener HttpListenerRegistry: Available listeners are: [(*)/callback/, (*)/]
Couple things might help. First off, make sure your FB App and Mule FB Config match on the "scope" Ex. "email,public_profile,user_friends".
Also, I solved part of this issue by creating a global HTTP element as the callback. The callback HTTP path needs to be "/*". Then in the Authorization FB component under the OAuth tab, I put the callback HTTP name as the HTTP Connector Reference.
<facebook:oauth-callback-config domain="localhost"
localPort="5000" remotePort="5000" connector-ref="callback"></facebook:oauth-callback-config>
</facebook:config-with-oauth>
<http:listener-config name="callback" host="0.0.0.0"
port="5000" basePath="/*" doc:name="HTTP Listener Configuration" />
I am getting started with Mule ESB. I am trying to build a SOAP proxy service that receives a SOAP request and redirects it to a SOAP service.
A simple example like this works fine -
<flow name="http_redirectFlow1" doc:name="http_redirectFlow1">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:8092/HelloProxyService" doc:name="HTTP"/>
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8080/soapsvc/hello" contentType="text/xml" doc:name="HTTP"/>
</flow>
Now I want to dump the contents of the request to a file. Which is the best way to do it? I tried to use the File connector by inserting this segment between the inbound and outbound endpoints -
<file:outbound-endpoint path="c:/temp" outputPattern="temp.txt" responseTimeout="10000" doc:name="File"/>
But that doesn't seem to work. I get an exception that says "Content must be set before entity is written". Not sure what it is, but I may be completely wrong in how I am doing. Please help....
Figured it out myself. I had to translate the DOM to XML using the dom-to-xml transformer. The XML dump is done as follows :-
<mulexml:dom-to-xml-transformer returnClass="java.lang.String"></mulexml:dom-to-xml-transformer>
<file:outbound-endpoint path="c:/temp" outputPattern="Dump_Rcvd.txt" responseTimeout="10000" doc:name="File" />
Thanks !
Alternately you can use <object-to-string-transformer doc:name="Object to String"/> before file:outbound-endpoint that will make the payload as a String format and can be written into a file easily
Use File Connector and Transformers involving Bytearray.
I tried to read a file and email through Mule. But it throws the following exception.
org.mule.api.transformer.TransformerException: Could not find a transformer to transform "SimpleDataType{type=javax.mail.internet.MimeMessage, mimeType='*/*'}" to "SimpleDataType{type=java.io.InputStream, mimeType='*/*'}".
at org.mule.registry.MuleRegistryHelper.lookupTransformer(MuleRegistryHelper.java:252)
at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:355)
at org.mule.DefaultMuleMessage.getPayload(DefaultMuleMessage.java:313)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
My mule file is as follows:
<flow name="Exception_HandlingFlow1" doc:name="Exception_HandlingFlow1">
<file:inbound-endpoint path="D:\WorkArea\COPA\In" responseTimeout="10000" doc:name="File Writer">
<file:file-to-string-transformer/>
</file:inbound-endpoint>
<component doc:name="Java" class="com.exhnlr.Handler.ExceptionHandler"/>
<smtps:outbound-endpoint host="192.168.131.139" responseTimeout="10000" doc:name="SMTP"
from="anbu1#bibs.com" subject="test" to="anbu1#bibs.com" user="anbu1" mimeType="text/plain">
<email:string-to-email-transformer/>
</smtps:outbound-endpoint>
</flow>
I have read a similiar link How to parse inbound e-mail when using Mule's IMAP transport?, but it didn't work for me.
Please help.
Add an <object-to-string-transformer /> after the file inbound endpoint.