Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Attachment problem with jaxm and Squid proxy  RSS feed

 
Christian Gruendemann
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I have found a strange behaviour when I am using the jaxm api.
As long as I am sending pure xml data everything works fine. When I try to add jpg pictures even this works, but if I use a squid proxy I get a strange javax.internet.mail.ParseException which is shown an the end of the mail. I have no idea why this happens, because without the squid proxy the jpg picture is sent correctly.
If someone of you have any idea I would really appriciate your help, because i ran out of ideas to solve that issue.
For more information I show you now some code fragments.
I am adding the picture like that
****************
data2 = new FileInputStream(new File("c:\picture.jpg"));
DataHandler dh = new DataHandler(new BinaryDataSource(data2));
AttachmentPart attachment2 = message.createAttachmentPart(dh);
attachment2.setContentType("image/jpeg");
attachment2.setContentId("some id");
message.addAttachmentPart(attachment2);
****************
the datahandler is like this
***********************
public class BinaryDataSource implements DataSource
{
private InputStream _is;
public BinaryDataSource(InputStream is)
{
_is = is;
}
public String getContentType()
{
return "application/binary";
}
public InputStream getInputStream() throws IOException
{
return _is;
}
public String getName()
{
return "some file";
}
public OutputStream getOutputStream() throws IOException
{
throw new IOException("Cannot write to this file");
}
an so on...
I found the description of the other datahandler which was posted in the
beginning of year in this list, but the exception is exactly the same.
I sniffed the soap data via axis tcpmon and the only difference is
in the HTTP header, which is normal when using a squid proxy, i guess.
** Sniffed soap data.
POST /Receiving/ReqRes HTTP/1.0
Content-Type: multipart/related; type="text/xml";
Content-Length: 106713
SOAPAction: ""
User-Agent: Java1.3.1_04
Host: x.x.x.x
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
***********
Via: 1.1 mail1.xxx.de:8081 (Squid/2.2.STABLE5)
*************
X-Forwarded-For: x.x.x.x
Cache-Control: max-age=259200
Connection: keep-alive
------=_Part_0_4283878.1038851232245
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Header/>
<soap-env:Body>
<m:transferData xmlns:m="urn:TransferToMatchMaker">
<CarBean>
.....
</CarBean>
</m:transferData>
</soap-env:Body></soap-env:Envelope>
------=_Part_0_4283878.1038851232245
Content-Type: image/jpeg
Content-Id: image/jpeg
*******
binary data comes here
******
Thanks for your help in advance,
Christian Gruendemann

***********
The Exception that is thrown by the server.
**********
H:\download\jwsdp-1_0_01\bin>catalina.bat run
Starting service Internal Services
Java Web Services Developer Pack/1.0_01-fcs
Starting service Java Web Services Developer Pack
Java Web Services Developer Pack/1.0_01-fcs
DEBUG: Picture Servlet
javax.mail.internet.ParseException
at javax.mail.internet.ParameterList.<init>(ParameterList.java:61)
at javax.mail.internet.ContentType.<init>(ContentType.java:83)
at com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:89)
at com.sun.xml.messaging.saaj.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:32)
at javax.xml.messaging.JAXMServlet.doPost(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2349)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:469)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:376)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:518)
at java.lang.Thread.run(Thread.java:479)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!