Multipart/related
Hi guys!
My first time on here so I hope this goes well!!
Ok, I'm on here because I have a problem. Basic jist of it is this. I'm trying to create a program which will read in emails. Everything was super until i recieved an email with the content type set as:
multipart related; type="multipart/alternative";
Any ideas as to how I can handle this because I'm totally stuck.
Thanks people!
Ah, that is the next mime type I need to implement for the webmail at webmail.ufl.edu that we're developing. When adding support for different mime types I found http://www.iana.org/assignments/media-types/ to be very useful. RFC2387 http://www.rfc-editor.org/rfc/rfc2387.txt describes multipart/related. Below is my current understanding, I could be wrong:
Basicly you'll find a few parameters: type, start, and start-info.
The start parameter may have a value that is a content-ID. If it does then that is the first part to show to the user, in most cases these days it will be the content-ID of a part of text/html and the other parts will be images. If the start parameter doesn't exists you use the first part inside the multipart/related.
The type parameter is required and it will be equal to the content-type of the "start" part. It's here so you don't have to look ahead too see what time time you're going to display to the user. I think I'll be ignoring it infavor of looking directly at the part but I don't know yet.
I'll let your read the RFC for info on start-info. It's optional and I don't think you're gonna need to worry about it unless you plan to fork processes to view a part.
So to display multipart/related you find your start part and present that to the user. All other nested parts you supress unless the start part requires them. In the case of a text/html start part you'll want to rewrite any <img src="cid:foo"> tags to something that references one of the image parts so it can be displayed inline in the html.
Hope that helps. If I found myself to be wrong I'll put up a follow up post.
Similar Messages
-
OSB defaulting Content-Type to "multipart/related" in case of attachments
I have scenario where I need to invoke a REST Webservice from OSB which accepts only media types which has "multipart/atom+xml". OSB is used for protocol transformation converting the SOAP request into the HTTP POST request with multipart. I have Proxy Service which will unwrap the message from the SOAP Body and post the same message into the payload of the Business Service and the attachment is passed 'as is' from the SOAP Service. The external REST Service Provider expects the media type to be "multipart/atom+xml", but in OSB when an attachment is present in the message, OSB is overrding the "Content-Type" proeprty to "multipart/related" inspite of me setting the "Content-Type" property of HTTP Transport Header in OSB and as result external RESTFUL Service is throwing "415-Unsupported Media Type" error. Below is the test results. One interesting thing is, it happens only when there is attachment present in the message. In case of a message which doesn't have attachment any "Content-Type" specified in the Transport Header is passed by the OSB to the external service. Any help is highly appreciated.
OSB Transport Header
Added the header <http:Content-Type>multipart/atom+xml</http:Content-Type>
Actual Raw Message
POST http://xxx7200:7004/XXXInterfaces/identify HTTP/1.1
Content-Type: multipart/related; type="text/plain"; start="<Root_-328322390>"; boundary=MIME_Boundary; charset=UTF-8
MIME-Version: 1.0
User-Agent: Java1.6.0_17
Host: xxx7200:7004
Accept: text/html, image/gif, image/jpeg, */*; q=.2
Proxy-Connection: Keep-Alive
Content-Length: 4823
Expected Raw Message
POST http://xxx7200:7004/XXXInterfaces/identify HTTP/1.1
Content-Type: multipart/atom+xml; boundary=MIME_Boundary;
User-Agent: Java1.6.0_17
Host: xxx7200:7004
Accept: text/html, image/gif, image/jpeg, */*; q=.2
Proxy-Connection: Keep-Alive
Content-Length: 4803
-KC
Edited by: 799459 on Apr 8, 2011 5:36 AM
Edited by: 799459 on Apr 8, 2011 7:02 AM
Edited by: 799459 on Apr 8, 2011 7:13 AM
Edited by: 799459 on Apr 8, 2011 7:14 AMHTTP content-type header has the following limitation as per osb doc.
Oracle Service Bus run time may overwrite these headers in the binding layer when preparing the message for dispatch. If these headers are modified, $inbound and $outbound are updated accordingly. So what you are seeing may be working as designed. Cant the remote service accept the multi part related content type set up by osb ? -
How to send HTML mail with images multipart/related message
Hi,
Could any body tell me how to send HTML mail with images in "multipart/related" message,if any body can give the code ,it would be helpful.
ThanksHi,
Could any body tell me how to send HTML mail with
ith images in "multipart/related" message,if any body
can give the code ,it would be helpful.
ThanksHi!
Refer to
http://developer.java.sun.com/developer/onlineTraining/JavaMail/index.html
I've found it very helpful.
Look at the last part for a code showing how to send HTML mail!
Regards -
MIME Multipart/related to embed images in html files - Servlet
Hello,
My goal is to embed images in html/xhtml files to decrease latency when using slow networks. Think about mobile phones, if I have 10 images in one page, I will have 11 requests/responses to get the whole page.
The solution would be to embed all images using Content-type multipart/related, so I have one request to the whole pack.
How to do that in java? I mean, I need to set the content-type and build all parts encoding the images to base64.
I tried JavaMail API, there I can build messages like this and instead of send an e-mail, I can write:
myMimeMultipart.writeTo(response.getOutputStream());
The problem is: I am getting everything as text in my browser, including the MIME headers of each part. Another think is that the first header (the main one) doesn't appear too.
Any thoughts/other ideas?
Thanks in advance,
Andr� CarlucciIf memory serves me right, I believe in the Servlet spec you have access to the Response object. You "should" be able to set any headers you need there. In addition, you can get the output streams just as you described.
I did a similar thing, although slightly modified, to output dynamically-generated XLS (Excel Spreadsheet) files using a reporting engine called JasperReports. It wasn't a multipart response, however, so you may need to figure out how to handle that part of it, but in my case I set the mime-type header, then grabbed the output and started writing my XLS file too it. Once done, you close the streams and return the response. Worked perfect. -
I have a Macbook Air. I have MS office installed and work in Excel often with no issues. But When I download an excel spread sheet from a Ford web site I seem to be getting code and not the work sheet.
Example-
MIME-Version: 1.0
X-Document-Type: Workbook
Content-Type: multipart/related; boundary="====Boundary===="
--====Boundary====
Content-Location: file:///C:/HOLD.XHT
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset="utf-8"
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<HEAD>
<meta name="Excel Workbook Frameset">
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>BTB</x:Name>
<x:WorksheetSource HRef="./IBIT0001.xht"/>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>GSM</x:Name>
<x:WorksheetSource HRef="./IBIT0002.xht"/>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>RODetail</x:Name>
<x:WorksheetSource HRef="./IBIT0003.xht"/>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
</HEAD>
</HTML>
--====Boundary====
Content-Location: file:///C:/IBIT0001.xht
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset="utf-8"
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<HEAD>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<style>
<!--table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
@page
{margin:1.0in .75in 1.0in .75in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-page-orientation:landscape;}
tr
{mso-height-source:auto;}
col
{mso-width-source:auto;}
br
{mso-data-placement:same-cell;}
.style21
{color:blue;
font-size:10.0pt;
font-weight:400;
font-style:normal;
text-decoration:underline;
text-underline-style:single;
font-family:Arial;Try search/ask in the forum devoted entirely to Excel issues:
http://answers.microsoft.com/en-us/mac/forum/macexcel -
Multipart/related part specifiers
Hi, this query is perhaps the result of my own limited knowledge regarding MIME types and part specifiers but here goes....
Based on the following BODYSTRUCTURE, I am attempting to determine the associated part specifiers so I may get the MIME headers for said part (i.e. A12 UID FETCH 147859 (BODY.PEEK[1.MIME])).
A11 UID FETCH 147859 (BODYSTRUCTURE)
* 1 FETCH (BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "QUOTED-PRINTABLE" 911 16 NIL NIL NIL)(("TEXT" "HTML" ("CHARSET" "US-ASCII") NIL NIL "QUOTED-PRINTABLE" 2716 46 NIL NIL NIL)("IMAGE" "BMP" ("name" "ExchangeBabs.bmp") "<297231021@11102006-1D66>" NIL "BASE64" 2634474 NIL ("inline" ("filename" "ExchangeBabs.bmp")) NIL)("APPLICATION" "OCTET-STREAM" ("name" "Presence_K1=XItJBkk1xQi8X5JIgeeyjkn9EJTYKfxg9AogMsw3qHMhNnawbZ5wVWrmDFYTq1yP&MODE=IMG") NIL NIL "BASE64" 732 NIL ("inline" ("filename" "Presence_K1=XItJBkk1xQi8X5JIgeeyjkn9EJTYKfxg9AogMsw3qHMhNnawbZ5wVWrmDFYTq1yP&MODE=IMG")) NIL)("IMAGE" "GIF" ("name" "Blank Bkgrd.gif") "<297231021@11102006-1D6D>" NIL "BASE64" 202 NIL ("inline" ("filename" "Blank Bkgrd.gif")) NIL) "related" ("boundary" "-------45363d5545363d55") NIL NIL) "alternative" ("boundary" "-------446e3c8d446e3c8d") NIL NIL) UID 147859)
The com.sun.mail.imap.protocol.BODYSTRUCTURE object generated is shown below (I've omitted most of the fields and left what I considered relevent, simply enough to show the nesting):
bs= BODYSTRUCTURE (id=181)
bodies= BODYSTRUCTURE[2] (id=199)
[0]= BODYSTRUCTURE (id=207)
bodies= null
encoding= "QUOTED-PRINTABLE"
subtype= "PLAIN"
type= "TEXT"
[1]= BODYSTRUCTURE (id=208)
bodies= BODYSTRUCTURE[4] (id=213)
[0]= BODYSTRUCTURE (id=216)
bodies= null
encoding= "QUOTED-PRINTABLE"
subtype= "HTML"
type= "TEXT"
[1]= BODYSTRUCTURE (id=217)
bodies= null
encoding= "BASE64"
subtype= "BMP"
type= "IMAGE"
[2]= BODYSTRUCTURE (id=218)
bodies= null
encoding= "BASE64"
subtype= "OCTET-STREAM"
type= "APPLICATION"
[3]= BODYSTRUCTURE (id=219)
bodies= null
encoding= "BASE64"
subtype= "GIF"
type= "IMAGE"
subtype= "related"
type= "multipart"
subtype= "alternative"
type= "multipart"This particular message has a multipart/related content-type:
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----_=_NextPart_001_01C6ED7A.EC20BF80"So, it has 4 part specifiers, one for each part in multipart/related. Now, the question to all this is can I determine from the BODYSTRUCTURE object what the root part is (i.e. that it's multipart/related)? Or am I going about this the wrong way (i.e. should I be examining the content-type header first to find out that its multipart/related and the first part is "text/html")?Basically, I'm trying to fetch various attributes of a message. In this case, the MIME headers of the various message parts (perhaps I'm stating the obvious but I'm not sure how to better explain what I'm trying to accomplish).
I've made some "progress". This morning when I continued working with the message described above, all of a sudden, the BODYSTRUCTURE I get back is different and as a result, the BODYSTRUCTURE object generated is different.
1 uid fetch 148032 (BODYSTRUCTURE)
* 1 FETCH (BODYSTRUCTURE (("TEXT" "HTML" ("charset" "iso-8859-1") NIL NIL "QUOTED-PRINTABLE" 2792 47 NIL NIL NIL)("IMAGE" "GIF" ("name" "Blank Bkgrd.gif") "<297231021@11102006-1D6D>" "Blank Bkgrd.gif" "BASE64" 202 NIL ("inline" ("filename" "Blank Bkgrd.gif")) NIL)("IMAGE" "BMP" ("name" "ExchangeBabs.bmp") "<297231021@11102006-1D66>" "ExchangeBabs.bmp" "BASE64" 2630728 NIL ("inline" ("filename" "ExchangeBabs.bmp")) NIL)("APPLICATION" "OCTET-STREAM" ("name" "Presence_K1=XItJBkk1xQi8X5JIgeeyjkn9EJTYKfxg9AogMsw3qHMhNnawbZ5wVWrmDFYTq1yP&MODE=IMG") NIL "Presence_K1=XItJBkk1xQi8X5JIgeeyjkn9EJTYKfxg9AogMsw3qHMhNnawbZ5wVWrmDFYTq1yP&MODE=IMG" "BASE64" 732 NIL ("inline" ("filename" "Presence_K1=XItJBkk1xQi8X5JIgeeyjkn9EJTYKfxg9AogMsw3qHMhNnawbZ5wVWrmDFYTq1yP&MODE=IMG")) NIL) "related" ("type" "text/html" "boundary" "----_=_NextPart_001_01C6ED7A.EC20BF80") NIL NIL) UID 148032)
1 OK FETCH completed.
bs= BODYSTRUCTURE (id=89)
bodies= BODYSTRUCTURE[4] (id=104)
[0]= BODYSTRUCTURE (id=115)
bodies= null
encoding= "QUOTED-PRINTABLE"
subtype= "HTML"
type= "TEXT"
[1]= BODYSTRUCTURE (id=116)
bodies= null
encoding= "BASE64"
subtype= "GIF"
type= "IMAGE"
[2]= BODYSTRUCTURE (id=117)
bodies= null
encoding= "BASE64"
subtype= "BMP"
type= "IMAGE"
[3]= BODYSTRUCTURE (id=118)
bodies= null
encoding= "BASE64"
subtype= "OCTET-STREAM"
type= "APPLICATION"
encoding= null
subtype= "related"
type= "multipart"NOTE: The UID differs from the previous example I'd given because I had archived the message and then moved it back to my Inbox.
Any ideas why the BODYSTRUCTURE reported by the server today is different from what it reported before? I have this message on both an Exchange 2000 and Mirapoint server. 2 days ago they both reported the BODYSTRUCTURE I indicated before, now they both have the BODYSTRUCTURE above.
PS. Sorry that this issue isn't really Javamail related anymore but I'd appreciate any input. -
Adding in-memory images to multipart/related
I'm constructing a multipart/related message and would like to add in-memory images to the MimeBodyPary instead of having JavaMail grab the images from the file system or from a URL.
Is there a simple way to do this using the JavaMail API? I think the solution might be to add a new DataSource implementation to the activation framework; something like a ByteArrayDataSource....Yes, that is the solution.
-
No object DCH for MIME type multipart/related
Hi, everyone!!!
When I execute my code, I got this exception:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/related
boundary="----=_Part_0_20851530.1186777547859"
the funny things is : I got it work before. However, when I come back a few days to run, it doesn't.
I use tomcat 5.0,
mail.jar: version: 1.6
activation.jar:version: I don't know but I download the new ones in sun website.
Note: Also, when I run the code below in standalone application (java application), it works but doesn't work on tomcat application
Any help would be appreciate.
I tried some helps tips from other website such as http://www.jguru.com/faq/view.jsp?EID=237257
and still doesn't work :((((
***********Here is my code**********
********props is properties file...............
Authenticator auth = new SMTPAuthenticator();
// Get session
Session session = Session.getDefaultInstance(props, auth);
session.setDebug(true);
// Create the message
Message message = new MimeMessage(session);
// Fill its headers
message.setSubject(subject);
message.setFrom(new InternetAddress(from));
for(int x=0;x<recipients.size();x++)
message.addRecipient(Message.RecipientType.TO, new InternetAddress(recipients.get(x).toString()));
// Create your new message part
BodyPart messBodyPart=new MimeBodyPart();
// Set the HTML content, be sure it references the attachment
String htmlText="<h1>Hi</h1>"+"<img src=\"cid:picture\">";
// Set the content of the body part
messBodyPart.setContent(htmlText, "text/html");
// Create a related multi-part to combine the parts
MimeMultipart multipart=new MimeMultipart("related");
// Add body part to multipart
multipart.addBodyPart(messBodyPart);
// Create part for the image
messBodyPart=new MimeBodyPart();
// Fetch the image and associate to part
System.out.println("before dataSource");
DataSource fds=new FileDataSource(this.getString("image_location"));
System.out.println("After dataSource");
messBodyPart.setDataHandler(new DataHandler(fds));
System.out.println("*************** dataSource");
// Add a header to connect to the HTML
messBodyPart.setHeader("Content-ID", "<picture>");
// Add part to multi-part
multipart.addBodyPart(messBodyPart);
// Associate multi-part with message
message.setContent(multipart);
// Send message
System.out.println("Before Send");
Transport.send(message);
System.out.println("Finish");
}Thank you for your response!!!
I already found the solution. For those who still having problem send e-mail, make sure to put mail.jar and activation.jar in the same location.
Also, make sure to check catalina.xml to make sure those jars are same location!!!->That what I found out.
->I put jars in same location of my eclipse project but it turns out, the tomcat app server didn't put them in same location.
Anyway, Thank you java_2006 for your response!!!!!
:) -
Unable to add Content-Type=multipart/related; type="text/xml";
hi all
am trying to add the following to my soap message that include attachment
but its not working
Content-Type=multipart/related; type="text/xml";
boundary="----=_Part_0_14732323.1039686671216";
Content-Length=4259;
can any body help plzzzzzzzzHello again,
My solution works and does not work. Content type is ok, but strange characters appear to the end of the attachment data.
Like this
...</E1EDS01></IDOC></ORDERS01>H úãž6×½ ã½5Õ×¼ÛgžÛNÝ}þ[ëMu201E
Where did these come from? I tested in a way that I changed the ContentType back to application/xml and attachment is fine again.
Regards,
Pekka -
JWSDP, WSDL and multipart/related problem
Hi,
I got a wsdl file that sends multipart/related soap messages and I want to generate a client stub using wscompile.
This is a short exerpt from the wsdl describing the message I want to send:
<wsdl:operation name="MessageSubmit">
<soap:operation/>
<wsdl:input>
<mime:multipartRelated>
<mime:part>
<soap:body use="literal"/>
</mime:part>
<mime:part>
<mime:content part="content" type="*/*"/>
</mime:part>
</mime:multipartRelated>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
The problem I have is that wscompile complains and says: "error: input message of binding operation "MessageSubmit" does not have a SOAP body extension". But it does! It's in there in the multipart/related tags.
The same wsdl works using tools from systinet. Doesn't JWSDP and wscompile handle multipart/related properly? Anyone else seen this?
Cheers,
Stefanwscompile does not support mime:multipart binding.
-
SUBSCRIBE failure: unrecognized format: 'multipart/related'
Hi,
In one of my network I have few SPA942 and one SPA504 with console SPA500S.
Asterisk is 1.4.22. After connecting to the network console SPA500S I have a small problem.
The console works fine but there are many such messages:
[Jun 13 09:42:46] WARNING[2938]: chan_sip.c:15456 handle_request_subscribe: SUBSCRIBE failure: unrecognized format: 'multipart/related' pvt: subscribed: 0, stateid: -1, laststate: 0, dialogver: 0, subscribecont: 'hinty', subscribeuri: ''
What may cause this symptom?
Best regards,
DanielHi,
I have a solution of this problem.
One of SPA942 had the error in configuration.
Best regards,
Daniel -
Help: Setting the multipart/related start parameter
I am wanting to set the "start" parameter on my ContentType header for
a multipart related message. Something like below.
DATA
ContentType: multipart/related; boundary=_XXX; start="<somecid@domain>"
I can set the content type to "multipart/related" by calling
MimeMultipart.setSubType(), but I cannot figure out how to set the
"start" parameter.
Anyone know.
Thanks,
ChrisDoes the SMTP server accept the mail for delivery of does it reject it?
If it doesn't reject it, is the issue with the format of the mime message, or possibly with whatever mail reader you are using.
It the SMTP server does reject the message I suppose the next question is what exactly is the "SMTP" server you are using?
IMHO you should not need to add anything to the mime multipart headers if using any RFC compliant SMTP server or reader. No-where in RFCs 2045,2046,2049,2822 etc can I find anything that relates to this "start" parameter.
If the SMTP server is a "proper" SMTP server it should not give two hoots about the mime multipart/mime body parts of the message as it "should" only be interested in the headers required to deliver the email. The mime multi/body part headers are generally not used to deliver. They are used by a Mime compliant mail reader to format and display the message.
We use Javamail to send regular "Newsletters" via a numbers of SMTP mail serviers running on IBM AS/400s, Sendmail on Unix, Lotus Notes servers and and others and have no problems.
If you want to send me your code to run on our systems to see if it really is your SMTP server or your message format that is giving trouble I can probably help. I can't open up a server for you as we have rather strict policies on who can do what with our servers. You can of course use our normal SMTP server to send a test email to me!!
Rgds,
SH -
Multipart/mixed and multipart/relative Content type probs
I tried to create a page from a servlet by using the multipart/mixed
Content-type.
All that is displayed inside the browser is the actual code including the
headers for the single parts of the page. I also checked it on the byte
level, getting the same results.
Does anybody have an idea ?
Thank you very much ,
Tom
Are you setting the content type prior to each response (i.e.
out.println("Content-type: text/html\n");)?
Below is an example (untested, but should work):
// Global constants
static final String BOUNDARY_STR ="Joe";
static final String BOUNDARY = "--"+BOUNDARY_STR;
static final String BOUNDARY_END = BOUNDARY+"--";
// Inside of doGet
res.setContentType("multipart/mixed;boundary="+BOUNDARY_STR);
ServletOutputStream out = res.getOutputStream();
// First Response
out.println(BOUNDARY);
out.println("Content-type: text/html\n");
out.println("<html>\n");
out.println("<head>\n");
out.println("<title>First Response</title>\n");
out.println("</head>\n");
out.println("<body>\n");
out.println("<h1>First Response</h1>\n");
out.println("</body>\n");
out.println("</html>\n");
out.println(BOUNDARY);
out.flush();
// Second Response
out.println(BOUNDARY);
out.println("Content-type: text/html\n");
out.println("<html>\n");
out.println("<head>\n");
out.println("<title>Second Response</title>\n");
out.println("</head>\n");
out.println("<body>\n");
out.println("<h1>Second Response</h1>\n");
out.println("</body>\n");
out.println("</html>\n");
out.println(BOUNDARY);
out.flush();
// Done
out.println(BOUNDARY_END);
out.flush();
Thomas Schmitt wrote in message <[email protected]>...
>I tried to create a page from a servlet by using the multipart/mixed
>Content-type.
>All that is displayed inside the browser is the actual code including the
>headers for the single parts of the page. I also checked it on the byte
>level, getting the same results.
>Does anybody have an idea ?
>Thank you very much ,
>Tom
>
>
-
Hi all,
I am wondering if OC4J 10.1.3 or 10.1.2 can handle document/literal Web Service with multipart attachment using JAX-RPC API.
I have created a prototype which does doc/lit WS with text/plain attachment without any problems on OC4J 10.1.3 DP 4.
But, no luck with multipart/related attachment. Our messaging system is designed that the first part is the SOAP envelope.
The second part is a multipart message, which could be nested.
Page 19-9 of Oracle Application Server Web Services Developer's Guide 10g Release 3 (10.1.3) B14434-01 (Sep. 2005)
does not have the multipart/* support for SWA attachment. It covers image/jpeg, image/gif, image/tif, text/plain, application/plain and text/xml.
Does anyone know if multipart is supported? Can you provide a working example please?
many thanks in advance !
---------WSDL ----------
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://service.topdown/"
name="bank"
targetNamespace="http://service.topdown/">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
elementFormDefault="qualified"
targetNamespace="http://service.topdown/">
<xsd:import namespace="http://ws-i.org/profiles/basic/1.1/xsd"
schemaLocation="http://mypc.company.com/xml/ws-i-basic-profile-1.1.xsd" /> <!-- TEMPORARY LOCATION TO AVOID PROXY SETUP -->
<complexType name="createAccount">
<sequence>
<element name="acctName" nillable="true" type="string"/>
<element name="initBalance" type="float"/>
</sequence>
</complexType>
<complexType name="createAccountResponse">
<sequence>
<element name="result" nillable="true" type="string"/>
</sequence>
</complexType>
<complexType name="AccountException">
<sequence>
<element name="message" nillable="true" type="string"/>
</sequence>
</complexType>
<complexType name="deposit">
<sequence>
<element name="acctID" nillable="true" type="string"/>
<element name="amount" type="float"/>
</sequence>
</complexType>
<complexType name="depositResponse">
<sequence/>
</complexType>
<complexType name="getAccountID">
<sequence>
<element name="acctName" nillable="true" type="string"/>
</sequence>
</complexType>
<complexType name="getAccountIDResponse">
<sequence>
<element name="result" nillable="true" type="string"/>
</sequence>
</complexType>
<complexType name="getBalance">
<sequence>
<element name="acctID" nillable="true" type="string"/>
<element name="acctName" nillable="true" type="string"/>
</sequence>
</complexType>
<complexType name="getBalanceResponse">
<sequence>
<element name="result" type="float"/>
</sequence>
</complexType>
<complexType name="withdraw">
<sequence>
<element name="acctID" nillable="true" type="string"/>
<element name="amount" type="float"/>
</sequence>
</complexType>
<complexType name="withdrawResponse">
<sequence/>
</complexType>
<!-- Added from attachment xsd -->
<complexType name="ClaimDetailType">
<xsd:sequence>
<element name="Name" type="xsd:string"/>
<element name="ClaimForm" type="ref:swaRef"/>
</xsd:sequence>
</complexType>
<element name="claimDetailElement" type="tns:ClaimDetailType"/>
<element name="claimResponseElement" type="ref:swaRef"/>
<!-- End of from attachment xsd -->
<element name="createAccountElement" type="tns:createAccount"/>
<element name="createAccountResponseElement" type="tns:createAccountResponse"/>
<element name="AccountExceptionElement" type="tns:AccountException"/>
<element name="depositElement" type="tns:deposit"/>
<element name="depositResponseElement" type="tns:depositResponse"/>
<element name="getAccountIDElement" type="tns:getAccountID"/>
<element name="getAccountIDResponseElement" type="tns:getAccountIDResponse"/>
<element name="getBalanceElement" type="tns:getBalance"/>
<element name="getBalanceResponseElement" type="tns:getBalanceResponse"/>
<element name="withdrawElement" type="tns:withdraw"/>
<element name="withdrawResponseElement" type="tns:withdrawResponse"/>
</schema>
</types>
<message name="BankService_depositResponse">
<part name="parameters" element="tns:depositResponseElement"/>
</message>
<message name="BankService_deposit">
<part name="parameters" element="tns:depositElement"/>
</message>
<message name="AccountException">
<part name="AccountExceptionElement" element="tns:AccountExceptionElement"/>
</message>
<message name="BankService_createAccount">
<part name="parameters" element="tns:createAccountElement"/>
</message>
<message name="BankService_withdrawResponse">
<part name="parameters" element="tns:withdrawResponseElement"/>
</message>
<message name="BankService_createAccountResponse">
<part name="parameters" element="tns:createAccountResponseElement"/>
</message>
<message name="BankService_getBalance">
<part name="parameters" element="tns:getBalanceElement"/>
</message>
<message name="BankService_getAccountIDResponse">
<part name="parameters" element="tns:getAccountIDResponseElement"/>
</message>
<message name="BankService_withdraw">
<part name="parameters" element="tns:withdrawElement"/>
</message>
<message name="BankService_getAccountID">
<part name="parameters" element="tns:getAccountIDElement"/>
</message>
<message name="BankService_getBalanceResponse">
<part name="parameters" element="tns:getBalanceResponseElement"/>
</message>
<!-- Added from attachment xsd -->
<message name="ClaimIn">
<part name="ClaimDetail" element="tns:claimDetailElement"/>
</message>
<message name="ClaimOut">
<part name="ClaimRefNo" element="tns:claimResponseElement"/>
</message>
<!-- Added from attachment xsd -->
<portType name="BankService">
<documentation>A service that provides banking operations for client applications.</documentation>
<operation name="SendClaim">
<input message="tns:ClaimIn"/>
<output message="tns:ClaimOut"/>
</operation>
<operation name="createAccount">
<documentation>Creates a banking account.</documentation>
<input message="tns:BankService_createAccount"/>
<output message="tns:BankService_createAccountResponse"/>
<fault name="AccountException" message="tns:AccountException"/>
</operation>
<operation name="deposit">
<documentation>Performs a bank deposit.</documentation>
<input message="tns:BankService_deposit"/>
<output message="tns:BankService_depositResponse"/>
<fault name="AccountException" message="tns:AccountException"/>
</operation>
<operation name="getAccountID">
<documentation>Retrieves an account ID.</documentation>
<input message="tns:BankService_getAccountID"/>
<output message="tns:BankService_getAccountIDResponse"/>
<fault name="AccountException" message="tns:AccountException"/>
</operation>
<operation name="getBalance">
<documentation>Retrieves an account balance.</documentation>
<input message="tns:BankService_getBalance"/>
<output message="tns:BankService_getBalanceResponse"/>
<fault name="AccountException" message="tns:AccountException"/>
</operation>
<operation name="withdraw">
<documentation>Withdraws funds from a bank account.</documentation>
<input message="tns:BankService_withdraw"/>
<output message="tns:BankService_withdrawResponse"/>
<fault name="AccountException" message="tns:AccountException"/>
</operation>
</portType>
<binding name="BankServicePortBinding" type="tns:BankService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="SendClaim">
<soap:operation soapAction="http://example.com/soapaction"/>
<input>
<mime:multipartRelated>
<mime:part>
<soap:body use="literal" parts="ClaimDetail" namespace="http://example.com/mimetypes"/>
</mime:part>
</mime:multipartRelated>
</input>
<output>
<mime:multipartRelated>
<mime:part>
<soap:body use="literal" namespace="http://example.com/mimetypes"/>
</mime:part>
</mime:multipartRelated>
</output>
</operation>
<operation name="createAccount">
<soap:operation soapAction="http://service.topdown/:createAccount"/>
<input>
<soap:body use="literal" parts="parameters"/>
</input>
<output>
<soap:body use="literal" parts="parameters"/>
</output>
<fault name="AccountException">
<soap:fault name="AccountException" use="literal" encodingStyle=""/>
</fault>
</operation>
<operation name="deposit">
<soap:operation soapAction="http://service.topdown/:deposit"/>
<input>
<soap:body use="literal" parts="parameters"/>
</input>
<output>
<soap:body use="literal" parts="parameters"/>
</output>
<fault name="AccountException">
<soap:fault name="AccountException" use="literal" encodingStyle=""/>
</fault>
</operation>
<operation name="getAccountID">
<soap:operation soapAction="http://service.topdown/:getAccountID"/>
<input>
<soap:body use="literal" parts="parameters"/>
</input>
<output>
<soap:body use="literal" parts="parameters"/>
</output>
<fault name="AccountException">
<soap:fault name="AccountException" use="literal" encodingStyle=""/>
</fault>
</operation>
<operation name="getBalance">
<soap:operation soapAction="http://service.topdown/:getBalance"/>
<input>
<soap:body use="literal" parts="parameters"/>
</input>
<output>
<soap:body use="literal" parts="parameters"/>
</output>
<fault name="AccountException">
<soap:fault name="AccountException" use="literal" encodingStyle=""/>
</fault>
</operation>
<operation name="withdraw">
<soap:operation soapAction="http://service.topdown/:withdraw"/>
<input>
<soap:body use="literal" parts="parameters"/>
</input>
<output>
<soap:body use="literal" parts="parameters"/>
</output>
<fault name="AccountException">
<soap:fault name="AccountException" use="literal" encodingStyle=""/>
</fault>
</operation>
</binding>
<service name="bank">
<port name="BankServicePort" binding="tns:BankServicePortBinding">
<soap:address location="http://localhost:8888/bank/bank"/>
</port>
</service>
</definitions>Thank you, Tim for your reply.
I found the answer myself. :-)
It's not the WSDL, it's the test program.
You are suggesting SWA attachment, which works. But, I am looking for SWAref attachment, which could be referenced by a SOAP element (i.e. cid: )
The client application builds a multipart, which has 1 text file and a jpeg file and sends
the multipart with SOAP envelope. The server returns the multipart back to the client.
Here is my client code:
private void demoAttachment() throws Exception
javax.xml.soap.MessageFactory mf = javax.xml.soap.MessageFactory.newInstance();
javax.xml.soap.SOAPMessage msg = mf.createMessage();
javax.xml.soap.AttachmentPart ap = msg.createAttachmentPart();
ap.addMimeHeader("header1", "12/28/2005");
// ap.setContent("Hello world !", "text/plain"); // text/plain worked earlier
MimeMultipart mmp = makeAttachment();
ap.setContent(mmp, mmp.getContentType());
javax.xml.soap.AttachmentPart ret = m_endpoint.sendClaim("John Smith", ap);
private static MimeMultipart makeAttachment()
MimeMultipart mp = new MimeMultipart();
try {
mp.setSubType("related");
} catch (MessagingException e1) {
e1.printStackTrace();
MimeBodyPart body1 = new MimeBodyPart();
try {
DataHandler dh = new DataHandler(new FileDataSource(TEXT_FILE_NAME));
body1.setDataHandler(dh);
String ct = dh.getContentType();
System.out.println("Content type: " + ct);
body1.setHeader("Content-Type", ct);
body1.setFileName("test.txt");
mp.addBodyPart(body1);
} catch (MessagingException e) {
e.printStackTrace();
MimeBodyPart body2 = new MimeBodyPart();
try {
DataHandler dh = new DataHandler(new FileDataSource(IMG_FILE_NAME));
body2.setDataHandler(dh);
String ct = dh.getContentType();
System.out.println("Content type: " + ct);
body2.setHeader("Content-Type", ct);
body2.setFileName("test.jpg");
mp.addBodyPart(body2);
} catch (MessagingException e) {
e.printStackTrace();
return mp;
-------- SOAP request and response -----------------------------------------
TcpTunnelText: ready to rock and roll on port 5555
TcpTunnelText: tunnelling port 5555 to port 8888 on host foo.bar.com
POST /topDownBank/topDownBank HTTP/1.1
Host: localhost:5555
Connection: Keep-Alive, TE
TE: trailers, deflate, gzip, compress
User-Agent: Oracle HTTPClient Version 10h
SOAPAction: "http://example.com/soapaction"
Accept-Encoding: gzip, x-gzip, compress, x-compress
Content-type: multipart/related;type="text/xml";boundary="----=_Part_1_33320514.1135808579711"
Content-length: 15957
------=_Part_1_33320514.1135808579711
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns0="http://service.topdown/"
xmlns:ns1="http://ws-i.org/profiles/basic/1.1/xsd">
<env:Body>
<ns0:claimDetailElement>
<ns0:Name>John Smith</ns0:Name>
<ns0:ClaimForm>cid:ID1@ClaimForm</ns0:ClaimForm>
</ns0:claimDetailElement>
</env:Body>
</env:Envelope>
------=_Part_1_33320514.1135808579711
Content-Type: multipart/related;
boundary="------=_Part_0_32113234.1135808579336"
header1: 12/28/2005
Content-Id: <ID1@ClaimForm>
------=_Part_0_32113234.1135808579336
Content-Type: text/plain; name=test.txt
Content-Disposition: attachment; filename=test.txt
Volume in drive C has no label.
Volume Serial Number is DCD8-0D94
Directory of C:\temp
12/22/2005 03:57 PM <DIR> .
12/22/2005 03:57 PM <DIR> ..
03/04/2005 02:28 PM <DIR> 0128
05/09/2005 09:10 PM 703 XMSTest1.java
58 File(s) 237,395,939 bytes
31 Dir(s) 49,375,744,000 bytes free
------=_Part_0_32113234.1135808579336
Content-Type: image/jpeg; name=test.jpg
Content-Disposition: attachment; filename=test.jpg
(binary data removed from here ...)
------=_Part_0_32113234.1135808579336--
------=_Part_1_33320514.1135808579711--
HTTP/1.1 200 OK
Date: Wed, 28 Dec 2005 22:22:59 GMT
Server: Oracle Containers for J2EE
Content-Length: 15922
Connection: Keep-Alive
Keep-Alive: timeout=15, max=100
Content-Type: multipart/related;type="text/xml";boundary="----=_Part_8_13238995.1135808579852"
SOAPAction: ""
------=_Part_8_13238995.1135808579852
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8" ?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns0="http://service.topdown/"
xmlns:ns1="http://ws-i.org/profiles/basic/1.1/xsd">
<env:Body>
<ns0:claimResponseElement>cid:ID1@claimResponseElement</ns0:claimResponseElement>
</env:Body>
</env:Envelope>
------=_Part_8_13238995.1135808579852
Content-Type: multipart/related;
boundary="------=_Part_0_32113234.1135808579336"
header1: 12/28/2005
Content-Id: <ID1@claimResponseElement>
------=_Part_0_32113234.1135808579336
Content-Type: text/plain; name=test.txt
Content-Disposition: attachment; filename=test.txt
Volume in drive C has no label.
Volume Serial Number is DCD8-0D94
Directory of C:\temp
12/22/2005 03:57 PM <DIR> .
12/22/2005 03:57 PM <DIR> ..
03/04/2005 02:28 PM <DIR> 0128
10/17/2005 03:54 PM 11,181,568 04_Tutorial_XMS_Webservices.doc
05/09/2005 09:10 PM 703 XMSTest1.java
58 File(s) 237,395,939 bytes
31 Dir(s) 49,375,744,000 bytes free
------=_Part_0_32113234.1135808579336
Content-Type: image/jpeg; name=test.jpg
Content-Disposition: attachment; filename=test.jpg
(binary data removed from here )
------=_Part_0_32113234.1135808579336--
------=_Part_8_13238995.1135808579852--
Message was edited by:
user457369 -
I've the following header and http request.
POST http://deab/DexNETWebServices_4_0_0_4/LoginService.svc HTTP/1.1
MIME-Version: 1.0
Content-Type: multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:e4c19840-745d-45b2-90ca-12d71be4cfd9+id=1";start-info="application/soap+xml"
VsDebuggerCausalityData: uIDPo5F/qXRc4YJImqB6Ard30cQAAAAAAjIXinpIVUulXLJOsSG7yyv7Lf2yHgpHlIxvc6oeqaAACQAA
Host: deab
Content-Length: 1017
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
--uuid:e4c19840-745d-45b2-90ca-12d71be4cfd9+id=1
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://tempuri.org/ILoginService/LoginByUserName</a:Action><a:MessageID>urn:uuid:cf410a05-23d4-4b92-a22c-329cbc19fbe7</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">http://deab/DexNETWebServices_4_0_0_4/LoginService.svc</a:To></s:Header><s:Body><LoginByUserName xmlns="http://tempuri.org/"><systemId>19e0ddb4-5fa5-41ee-b624-aea762865a6c</systemId><strName>FirmwareUpdateLogQueryWorker</strName><productId>0af39a3e-6549-485b-872f-b73413203998</productId><password>abc</password></LoginByUserName></s:Body></s:Envelope>
--uuid:e4c19840-745d-45b2-90ca-12d71be4cfd9+id=1--
I'm using the following code to set the header from PL/SQL and call the request. But UTL_HTTP.get_response returns the error 400 Bad Request.
DECLARE
l_request CLOB;
l_http_req UTL_HTTP.req;
l_http_resp UTL_HTTP.resp;
v_buffer VARCHAR2 (32767);
p_status_code NUMBER (9);
p_error_message VARCHAR2 (32767);
p_response CLOB;
BEGIN
l_request :=
'--uuid:e4c19840-745d-45b2-90ca-12d71be4cfd9+id=1'
|| CHR (13)
|| 'Content-ID: <http://tempuri.org/0>'
|| CHR (13)
|| 'Content-Transfer-Encoding: 8bit'
|| CHR (13)
|| 'Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"'
|| CHR (13)
|| CHR (13)
|| '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://tempuri.org/ILoginService/LoginByUserName</a:Action><a:MessageID>urn:uuid:cf410a05-23d4-4b92-a22c-329cbc19fbe7</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo><a:To s:mustUnderstand="1">http://deab/DexNETWebServices_4_0_0_4/LoginService.svc</a:To></s:Header><s:Body><LoginByUserName xmlns="http://tempuri.org/"><systemId>'
|| '19e0ddb4-5fa5-41ee-b624-aea762865a6c'
|| '</systemId><strName>'
|| 'FirmwareUpdateLogQueryWorker'
|| '</strName><productId>'
|| '0af39a3e-6549-485b-872f-b73413203998'
|| '</productId><password>'
|| 'abc'
|| '</password></LoginByUserName></s:Body></s:Envelope>'
|| CHR (13)
|| '--uuid:e4c19840-745d-45b2-90ca-12d71be4cfd9+id=1--';
DBMS_OUTPUT.put_line ('request ' || l_request);
l_http_req := UTL_HTTP.begin_request ('http://deab/DexNETWebServices_4_0_0_4/LoginService.svc', 'POST', 'HTTP/1.1');
UTL_HTTP.set_header (l_http_req, 'MIME-Version', '1.0');
UTL_HTTP.set_header (
l_http_req,
'Content-Type',
'multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:e4c19840-745d-45b2-90ca-12d71be4cfd9+id=1";start-info="application/soap+xml"');
-- UTL_HTTP.set_header (l_http_req, 'Content-ID', '<http://tempuri.org/0>');
-- UTL_HTTP.set_header (l_http_req, 'Content-Transfer-Encoding', '8bit');
UTL_HTTP.set_header (
l_http_req,
'VsDebuggerCausalityData',
'uIDPo5F/qXRc4YJImqB6Ard30cQAAAAAAjIXinpIVUulXLJOsSG7yyv7Lf2yHgpHlIxvc6oeqaAACQAA');
UTL_HTTP.set_header (l_http_req, 'Content-Length', LENGTH (l_request));
-- UTL_HTTP.set_header (l_http_req,
-- 'SOAPAction',
-- 'http://tempuri.org/ILoginService/LoginByUserName');
UTL_HTTP.write_text (l_http_req, l_request);
DBMS_LOB.createtemporary (p_response, FALSE);
l_http_resp := UTL_HTTP.get_response (l_http_req);
BEGIN
LOOP
UTL_HTTP.read_text (l_http_resp, v_buffer, 32767);
DBMS_OUTPUT.put_line (v_buffer);
DBMS_LOB.writeappend (p_response, LENGTH (v_buffer), v_buffer);
END LOOP;
EXCEPTION
WHEN UTL_HTTP.end_of_body
THEN
NULL;
END;
UTL_HTTP.end_response (l_http_resp);
p_status_code := l_http_resp.status_code;
p_error_message := l_http_resp.reason_phrase;
p_response := REPLACE (p_response, '<', '<');
p_response := REPLACE (p_response, '>', '>');
DBMS_OUTPUT.put_line (
'Status: ' || p_status_code || '-' || p_error_message || ': ' || p_response);
END;
Thank you for your help on this.HI Michiel
I am also trying to achieve something similar to that. I am trying to call a web service that sends an xml attachment over MTOM? Kindly, let me know if this was achievable from your end? I mean how did the issue got resolved.
thanks
vijay
Maybe you are looking for
-
Adobe Acrobat Pro 9 Crashes when trying to save pdf as Word doc.
It starts to save the document and says page pass 1 of 5 for example then says adobe acrobat has stopped working. How do I fix this problem?
-
HT201269 how do I get my music from my Iphone3 to my Iphone4 off Itunes?
How do I get my music from my Iphone3 to my Iphone4 off Itunes?
-
Why my minimized JFrame dosen't blink...
Hi, i m trying to built a small local messenger where i am opening a new window by clicking on the user name as like normal messenger... no my problem is that if the chat window that appears after clicking on username is mimimized and some it receive
-
Importing XMP sidecar with PSD files
I've got a boatload of PSD files in Aperture with keywords and other metadata. I want to import these into LR5. Aperture will not (AFAIK) write the metadata I have in Aperture to the files themselves since they are PSDs. But it does write to XMP file
-
when I import my RAW files from my memory card into iPhoto it does some kind of editing without me even doing anything. How can I prevent this? It's making all of my photos seem washed out, the JPG versions are fine, it's only adjusting the RAW files