Extracting SOAP Attachments!! Help!!
Hello all,
I have written a web service receiving soap message with attachments.
message is like below. I also written a message handler at the service side to extract attachments.
and its invoke method is like this.
public void invoke(MessageContext arg0) throws AxisFault {
SOAPMessage soapMessage = arg0.getMessage();
Iterator attachments = soapMessage.getAttachments();
while(attachments.hasNext()){
AttachmentPart attachment = (AttachmentPart)attachments.next();
System.out.println("ATTACHMENT CONTENT ID=" + attachment.getContentId());
System.out.println("ATTACHMENT CONTENT LOCATION="+ attachment.getContentLocation());
System.out.println("ATTACHMENT CONTENT TYPE="+ attachment.getContentType());
DataHandler dh = attachment.getDataHandler();
String attachmentContent = CfDataSourceReader.convertToString(dh.getDataSource());
System.out.println("ATTACHMENT CONTTENT BODY=" + attachmentContent);
i get one attachment and print it like this, although i have two attachment.
------=_Part_34_14069871.1239527371546
Content-Type: multipart/mixed; boundary="----=_Part_38987_26662994.1239527475525"
Content-Transfer-Encoding: binary
Content-Id: <82EBE43CF308A233A1F44B98520D944D>
------=_Part_38987_26662994.1239527475525
Content-Type: application/smil; filename=p.smil; name=p.smil; charset=utf-8
Content-Transfer-Encoding: 7bit
Content-ID: <d6T40>
Content-Location: p.smil
Content-Disposition: Attachment ;Filename="p.smil"
<smil>
<head>
<layout>
<root-layout width="115" height="122" />
<region id="Image" width="100%" height="100%" left="0%" top="0%" fit="meet" />
</layout>
</head>
<body>
<par dur="6000ms">
</par>
</body>
</smil>
------=_Part_38987_26662994.1239527475525
Content-Type: image/jpeg; filename=XXXXXXXXXXXXX.jpg; name=XXXXXXXXXXXXXXXX.jpg
Content-Transfer-Encoding: base64
Content-Location: XXXXXXXXXXXXXX.jpg
Content-Disposition: Attachment ;Filename="XXXXXXXXXXXXX.jpg"
Content-ID: <31loDbypsW>
//////////////BNARYY CONTENT ///////////////////
------=_Part_38987_26662994.1239527475525--
* How can i get those two attachment file contents ?? PLS HELP!!!!!! *
------=_Part_34_14069871.1239527371546
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-Id: <A58B5257C0B0A1A6C8C8DAC18A19B75D>
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Header>
<mm7:TransactionID SOAP-ENV:mustUnderstand="1" xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">XXXXXXXXXXXXXXXXXXXXXXXXXXXX</mm7:TransactionID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<mm7:DeliverReq xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">
<MM7Version>5.3.0</MM7Version>
<LinkedID>XXXXXXXXXXXXXXXXXXXXXXXXXXXX</LinkedID>
<Subject></Subject>
<Sender>
<Number>XXXXXXXXXXXXXXXXX</Number>
</Sender>
<Recipients><To><Number>3300</Number></To></Recipients>
<TimeStamp>2009-04-12T12:11:14Z</TimeStamp>
<Priority>Normal</Priority>
</mm7:DeliverReq>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
------=_Part_34_14069871.1239527371546
Content-Type: multipart/mixed; boundary="----=_Part_38987_26662994.1239527475525"
Content-Transfer-Encoding: binary
Content-Id: <82EBE43CF308A233A1F44B98520D944D>
------=_Part_38987_26662994.1239527475525
Content-Type: application/smil; filename=p.smil; name=p.smil; charset=utf-8
Content-Transfer-Encoding: 7bit
Content-ID: <d6T40>
Content-Location: p.smil
Content-Disposition: Attachment ;Filename="p.smil"
<smil>
<head>
<layout>
<root-layout width="115" height="122" />
<region id="Image" width="100%" height="100%" left="0%" top="0%" fit="meet" />
</layout>
</head>
<body>
<par dur="6000ms">
</par>
</body>
</smil>
------=_Part_38987_26662994.1239527475525
Content-Type: image/jpeg; filename=XXXXXXXXXXXXX.jpg; name=XXXXXXXXXXXXXXXX.jpg
Content-Transfer-Encoding: base64
Content-Location: XXXXXXXXXXXXXX.jpg
Content-Disposition: Attachment ;Filename="XXXXXXXXXXXXX.jpg"
Content-ID: <31loDbypsW>
//////////////BNARYY CONTENT ///////////////////
------=_Part_38987_26662994.1239527475525--
------=_Part_34_14069871.1239527371546--
You can try this code to extract the attachments
while (attachments.hasNext())
AttachmentPart att = (AttachmentPart)attachments.next();
contentId=att.getContentId();
int i=contentId.lastIndexOf('\\');
String filename=contentId.substring(i);
file = new FileOutputStream("D:\\"+filename);
InputStream is = att.getRawContent();
byte[] buff = new byte[1024];
int read = 0;
while ((read = is.read(buff, 0, buff.length)) != -1) {
file.write(buff, 0, read);
file.flush();
file.close();
where content id has path name of file.
Similar Messages
-
Extract SOAP Header from JMS Adapter PartnerLink
Hi Chintan,
I have next problem:
I have a JMS queue. The message in this queue are "SOAP Message" with Body and SOAP Header.
I have developed a "BPEL JMS service" with a JMS Adapter PartnerLink.I need extract SOAP Header from PartnetLink JMS Adapter, but with headerVariable into "Receive activity" it´s not work OK.
Could anybody help me with this problems?
Thanks a lot.
Regards.HI,
Try your luck at this link
http://orasoa.blogspot.com/2007/09/using-custom-headers-in-bpel.html -
Problem extracting SOAP XML payload using pl/sql
Hi,
I was wondering if I could get some help on extracting the address matches that are returned from the Web Service I am consuming. This is the first time I have dealt with XML and web services. I'm using Oracle 10.2.0.1.
The response I’m getting back returns 4 address matches (shown below against n2, n4, n6 and n8) which is:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><searchResponse
xmlns="http://ws.aplt.msi.com"><searchReturn><?xml version="1.0"
encoding="UTF-8" standalone="yes"?>
<GetAddressSearchResponse
xmlns="http://aplt.nzpost.co.nz/schemas/search">
<ns1:ResponseHeader
xmlns:ns1="http://aplt.nzpost.co.nz/schemas/common">
<ns1:Errors/>
</ns1:ResponseHeader>
<SearchResults SearchType="StreetAddress">
<ResultRecord Type="URBAN">
<ns2:AddressDetails
xmlns:ns2="urn:nzpost:schemas:xAL:3.0">
<ns2:Locality>
<ns2:Name>LOWER HUTT</ns2:Name>
<ns2:DependentLocality>
<ns2:Name>WAINUIOMATA</ns2:Name>
</ns2:DependentLocality>
</ns2:Locality>
<ns2:Thoroughfare>
<ns2:Name>MAIN ROAD</ns2:Name>
<ns2:Number>
<ns2:Number Type="number">111</ns2:Number>
</ns2:Number>
</ns2:Thoroughfare>
<ns2:Postal>
<ns2:PostalCode>
<ns2:Number>
<ns2:Number>5014</ns2:Number>
</ns2:Number>
</ns2:PostalCode>
</ns2:Postal>
</ns2:AddressDetails>
<DPID>494852</DPID>
<Geospatial>
<ns3:Point
xmlns:ns3="http://aplt.nzpost.co.nz/schemas/common">
<ns3:Coordinate>174.953883,-41.271187</ns3:Coordinate>
</ns3:Point>
</Geospatial>
</ResultRecord>
<ResultRecord Type="URBAN">
<ns4:AddressDetails
xmlns:ns4="urn:nzpost:schemas:xAL:3.0">
<ns4:Locality>
<ns4:Name>UPPER HUTT</ns4:Name>
</ns4:Locality>
<ns4:Thoroughfare>
<ns4:Name>MAIN STREET</ns4:Name>
<ns4:Number>
<ns4:Number
Type="number">111</ns4:Number>
<ns4:Number
Type="alpha">A</ns4:Number>
</ns4:Number>
</ns4:Thoroughfare>
<ns4:Postal>
<ns4:PostalCode>
<ns4:Number>
<ns4:Number>5018</ns4:Number>
</ns4:Number>
</ns4:PostalCode>
</ns4:Postal>
</ns4:AddressDetails>
<DPID>2697192</DPID>
<Geospatial>
<ns5:Point
xmlns:ns5="http://aplt.nzpost.co.nz/schemas/common">
<ns5:Coordinate>175.070066,-41.124317</ns5:Coordinate>
</ns5:Point>
</Geospatial>
</ResultRecord>
<ResultRecord Type="URBAN">
<ns6:AddressDetails
xmlns:ns6="urn:nzpost:schemas:xAL:3.0">
<ns6:Locality>
<ns6:Name>WELLINGTON</ns6:Name>
<ns6:DependentLocality>
<ns6:Name>TAWA</ns6:Name>
</ns6:DependentLocality>
</ns6:Locality>
<ns6:Thoroughfare>
<ns6:Name>MAIN ROAD</ns6:Name>
<ns6:Number>
<ns6:Number Type="number">111</ns6:Number>
</ns6:Number>
</ns6:Thoroughfare>
<ns6:Postal>
<ns6:PostalCode>
<ns6:Number>
<ns6:Number>5028</ns6:Number>
</ns6:Number>
</ns6:PostalCode>
</ns6:Postal>
</ns6:AddressDetails>
<DPID>1066466</DPID>
<Geospatial>
<ns7:Point
xmlns:ns7="http://aplt.nzpost.co.nz/schemas/common">
<ns7:Coordinate>174.824326,-41.174181</ns7:Coordinate>
</ns7:Point>
</Geospatial>
</ResultRecord>
<ResultRecord Type="URBAN">
<ns8:AddressDetails
xmlns:ns8="urn:nzpost:schemas:xAL:3.0">
<ns8:Locality>
<ns8:Name>WELLINGTON</ns8:Name>
<ns8:DependentLocality>
<ns8:Name>KARORI</ns8:Name>
</ns8:DependentLocality>
</ns8:Locality>
<ns8:Thoroughfare>
<ns8:Name>MAKARA ROAD</ns8:Name>
<ns8:Number>
<ns8:Number Type="number">111</ns8:Number>
</ns8:Number>
</ns8:Thoroughfare>
<ns8:Postal>
<ns8:PostalCode>
<ns8:Number>
<ns8:Number>6012</ns8:Number>
</ns8:Number>
</ns8:PostalCode>
</ns8:Postal>
</ns8:AddressDetails>
<Geospatial>
<ns9:Point
xmlns:ns9="http://aplt.nzpost.co.nz/schemas/common">
<ns9:Coordinate>174.717753 , -41.284415</ns9:Coordinate>
</ns9:Point>
</Geospatial>
</ResultRecord>
</SearchResults>
</GetAddressSearchResponse>
</searchReturn></searchResponse></soapenv:
Body></soapenv:Envelope>
My cursor that gets any errors returned appears ok. This is:
CURSOR c_xml_err(i_xml IN XMLType, i_xmlns IN VARCHAR2) IS
SELECT extract(value(xmlseq), '/Errors' , i_xmlns) vi_errors
,extract(value(xmlseq), '/Warnings' , i_xmlns) vi_warnings
FROM TABLE(xmlSequence(extract(i_xml, '/GetAddressSearchResponse/ns1:ResponseHeader' , i_xmlns))) xmlseq;
i_xml that is passed in is an XMLType converted from a CLOB which is the response from the web service:
v_xml_response := XMLType(i_response);
i_response is the SOAP package above with the following done on it:
-- Strip the unnecessary SOAP XML envelope from the response
v_xml_resp := XMLType.createXml(o_response);
i_response := v_xml_resp.extract('/soap:Envelope/soap:Body/child::node()'
,'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"').getClobVal();
i_response is defined with a type of CLOB.
i_xmlns that is passed in is: 'xmlns:ns1="' || i_xml_namespace || '"' where i_xml_namespace is: http://aplt.nzpost.co.nz/schemas/search
My cursor that tries to get the address details returned is:
CURSOR c_xml(i_xml IN XMLType, i_xmlns IN VARCHAR2) IS
SELECT extract(value(xmlseq), '/ResultRecord/AddressDetails/Postal.PostBox.Number/text()' , i_xmlns).getNumberVal() box#
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Thoroughfare.Number/text()' , i_xmlns).getStringVal() street_number
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Thoroughfare.Name/text()' , i_xmlns).getStringVal() street_name
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Locality.DependentLocality.Name/text()' , i_xmlns).getStringVal() suburb
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Locality.Name/text()' , i_xmlns).getStringVal() town_city
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Postal.PostalCode.Number/text()' , i_xmlns).getStringVal() post_code
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Postal.PostOffice.Name/text()' , i_xmlns).getStringVal() box_lobby_name
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Postal.PostRoute.Name/text()' , i_xmlns).getStringVal() rd_number
FROM TABLE(xmlSequence(extract(i_xml, '/GetAddressSearchResponse/SearchResults' , i_xmlns))) xmlseq;
This is not correct because it doesn’t select anything. The i_xml parameter passed in is the same as above however the i_xmlns parameter that is passed into this cursor is different. It’s currently passed in as:
'xmlns:ns2="urn:nzpost:schemas:xAL:3.0"'
Which matches what is returned in the soap message (first the first address match returned):
<ResultRecord Type="URBAN">
<ns2:AddressDetails
xmlns:ns2="urn:nzpost:schemas:xAL:3.0">
I'm calling this cursor in loop as follows:
for r_cu in c_xml(v_xml_response, v_xml_namespace)
loop
dbms_output.put_line('***** test12 - ws_avs_clients - IN LOOP - delete/insert nzp23_address');
Nothing gets returned.
Firstly, I’m not sure how to cater for n2, n3, n4, n5, etc which are the namespaces returned and incremented for each address match.
I’m also wondering if my cursor should be changed to something like:
CURSOR c_xml(i_xml IN XMLType, i_xmlns IN VARCHAR2) IS
SELECT extract(value(xmlseq), '/Postal.PostBox.Number/text()' , i_xmlns).getNumberVal() box#
,extract(value(xmlseq), '/Thoroughfare.Number/text()' , i_xmlns).getStringVal() street_number
,extract(value(xmlseq), '/Thoroughfare.Name/text()' , i_xmlns).getStringVal() street_name
,extract(value(xmlseq), '/Locality.DependentLocality.Name/text()' , i_xmlns).getStringVal() suburb
,extract(value(xmlseq), '/Locality.Name/text()' , i_xmlns).getStringVal() town_city
,extract(value(xmlseq), '/Postal.PostalCode.Number/text()' , i_xmlns).getStringVal() post_code
,extract(value(xmlseq), '/Postal.PostOffice.Name/text()' , i_xmlns).getStringVal() box_lobby_name
,extract(value(xmlseq), '/Postal.PostRoute.Name/text()' , i_xmlns).getStringVal() rd_number
FROM TABLE(xmlSequence(extract(i_xml, '/GetAddressSearchResponse/SearchResults/ResultRecord/ns2:AddressDetails' , i_xmlns))) xmlseq;
However I couldn’t have the ns2: before “AddressDetails” because this gets incremented. I don’t think I can also have the i_xmlns namespace parameter passed in as 'xmlns:ns2="urn:nzpost:schemas:xAL:3.0"'
because the ns2 gets incremented for each address.
I'm looking for any examples of pl/sql code that extracts the addresses from the SOAP message returned like I’m trying to do?
Any help would be much appreciated.
Thanks,
BradYou can find some examples in both the {forum:id=34} and {forum:id=75} forums. Just search on soap:Envelope or soap:Body and you should get some hits back.
Since you are using 10.2, you will want to use XMLTable instead of TABLE(xmlSequence(extract as XMLTable is the direction Oracle is going. As for ns2:, ns4: it doesn't matter what namespace prefix you use in your XPath statement as long as all the prefixes resolve to the same namespace.
Here is a starter piece of code that puts all that together for you.
SELECT town_city, peeking
FROM XMLTABLE(XMLNamespaces(default 'http://aplt.nzpost.co.nz/schemas/search',
'urn:nzpost:schemas:xAL:3.0' as "adns"),
'/GetAddressSearchResponse/SearchResults/ResultRecord/adns:AddressDetails'
PASSING XMLTYPE('<GetAddressSearchResponse xmlns="http://aplt.nzpost.co.nz/schemas/search">
<SearchResults SearchType="StreetAddress">
<ResultRecord Type="URBAN">
<ns2:AddressDetails xmlns:ns2="urn:nzpost:schemas:xAL:3.0">
<ns2:Locality>
<ns2:Name>LOWER HUTT</ns2:Name>
</ns2:Locality>
</ns2:AddressDetails>
</ResultRecord>
<ResultRecord Type="URBAN">
<ns4:AddressDetails xmlns:ns4="urn:nzpost:schemas:xAL:3.0">
<ns4:Locality>
<ns4:Name>UPPER HUTT</ns4:Name>
</ns4:Locality>
</ns4:AddressDetails>
</ResultRecord>
</SearchResults>
</GetAddressSearchResponse>')
-- The above XMLType would be your variable instead of what is hard-coded
COLUMNS
town_city VARCHAR2(30) PATH '/adns:AddressDetails/adns:Locality/adns:Name',
peeking XMLTYPE PATH '.'); -- This var is just to show you what each iteration is working with.You can also assign a namespace prefix to one of the default namespaces if your XPath goes across multiple "default" namespaces.
SELECT town_city, peeking
FROM XMLTABLE(XMLNamespaces('http://aplt.nzpost.co.nz/schemas/search' as "def", -- made up this prefix
'urn:nzpost:schemas:xAL:3.0' as "adns"),
'/def:GetAddressSearchResponse/def:SearchResults/def:ResultRecord/adns:AddressDetails'
PASSING XMLTYPE('<GetAddressSearchResponse xmlns="http://aplt.nzpost.co.nz/schemas/search">
<SearchResults SearchType="StreetAddress">
<ResultRecord Type="URBAN">
<ns2:AddressDetails xmlns:ns2="urn:nzpost:schemas:xAL:3.0">
<ns2:Locality>
<ns2:Name>LOWER HUTT</ns2:Name>
</ns2:Locality>
</ns2:AddressDetails>
</ResultRecord>
<ResultRecord Type="URBAN">
<ns4:AddressDetails xmlns:ns4="urn:nzpost:schemas:xAL:3.0">
<ns4:Locality>
<ns4:Name>UPPER HUTT</ns4:Name>
</ns4:Locality>
</ns4:AddressDetails>
</ResultRecord>
</SearchResults>
</GetAddressSearchResponse>')
-- The above XMLType would be your variable instead of what is hard-coded
COLUMNS
town_city VARCHAR2(30) PATH '/adns:AddressDetails/adns:Locality/adns:Name',
peeking XMLTYPE PATH '.'); -- This var is just to show you what each iteration is working with.Hope that helps as a starter to working on your problem.
If you follow the FAQ link in the above right, you will see how to use the { code } tag (without spaces) to wrap the examples and retain formatting as shown above. -
Retriving .doc and .rtf files in soap attachments
Please help me
I'm using JAXM to retrive soap attachments
When i retrive txt files (.txt) it retrivs the content of the document
without any problem but when i try to retrive .doc or rtf
it gives content as
java.io.FileInputStream@587c94
(retrive attached files which are recived from client)
how do i get the content from word or rtf document
this is the way i tried to get the content
while (it.hasNext()) {
AttachmentPart ap = (AttachmentPart)it.next();
contentType = ap.getContentType();
content =(String)ap.getContent();
p.println("content---->"+content);//wrriting to text file
System.out.println("*** attachment content: " + content);
thanks namsHere is the code I used to send and receive a PDF file as a SOAP attachment. Note that if the sender uses a DataHandler for the attachment's content, there's no need to set the MIME type explicitly because the DataHandler does it for you.
* Sender
// create the data source and data handler
DataSource source = new FileDataSource("form.pdf");
DataHandler handler = new DataHandler(source);
// create attachment for message
AttachmentPart attachment = message.createAttachmentPart(handler);
// set content id (optional)
attachment.setContentId("enrollment_form");
// add attachment to message
message.addAttachmentPart(attachment);
// send message
providerConnection.send(message);
* Recipient
public class Receiver extends JAXMServlet implements OnewayListener {
public void onMessage(SOAPMessage message) {
// get attachment
Iterator it = message.getAttachments();
AttachmentPart attachment = (AttachmentPart) it.next();
if (attachment.getContentType().equals("application/pdf")) {
// read contents into byte buffer
ByteArrayInputStream contentStream =
(ByteArrayInputStream)attachment.getContent();
// use standard Java I/O methods to save in file
int bytesToRead = contentStream.available();
byte[] buffer = new byte[bytesToRead];
contentStream.read(buffer);
// write buffer to new file
FileOutputStream file = new FileOutputStream("form.pdf");
file.write(buffer);
file.close();
log("Attachment " + attachment.getContentId() + " with type "
+ attachment.getContentType() + " written to form.pdf");
else {
log("attachment content has MIME type " + attachment.getContentType()
+ ", Java type " + attachment.getContent().getClass());
} -
i have writen a code to send soap attachments from client to server
In the code below i 'm sending txt file and xml file from client to server
when i see the value of msg.countAttachments();it 's value is 2 that mean two attachments are reciving with ut no problem
now i want to save both attachments in servermachine c:/ directory how do i di that
i tried to access the attachment like this
java.util.Iterator it = msg.getAttachments();
while (it.hasNext()) {
AttachmentPart attachment = (AttachmentPart)it.next();
Object content = attachment.getContent();
for more clear below -client code attaching part
FileDataSource fds = new FileDataSource(m_attachment);
DataHandler dh = new DataHandler(fds);
AttachmentPart ap1 = msg.createAttachmentPart(dh);
msg.addAttachmentPart(ap1);
AttachmentPart ap2 = msg.createAttachmentPart("Another Part","text/plain; charset=ISO-8859-1");
msg.addAttachmentPart(ap2);
msg.saveChanges();
//create the endpoint and send the message
URL endpoint = new URL("http://localhost:8080/jaxm-coffee-supplier/getPriceList");
SOAPMessage response = con.call(msg, endpoint);
ThanksHello!
I'm sure you already solved the problem you had and I hope you can help me out with my little problem. I want to create a file upload with a web service. I copied the code from sun's tutorial (and now from your post), but I constantly get the NullPointerException on the call:
AttachmentPart attachment = msg.createAttachmentPart()
(or AttachmentPart attachment = msg.createAttachmentPart(dataHandler);)
Can you please tell me what's wrong with my code?
Thnx in advanced, D
(BTW here is my code:)
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPMessage;
public class client01 {
public static void main(String args[]) throws Exception, MalformedURLException {
MessageFactory factory = MessageFactory.newInstance();
Message msg = factory.createMessage();
ConnectionFactory soapConnectionFactory = ConnectionFactory.newInstance();
Connection con = soapConnectionFactory.createConnection();
FileDataSource fds = new
FileDataSource("C:"+File.separator+"image"+File.separator+"test01.jpg");
DataHandler dh = new DataHandler(fds);
AttachmentPart attachment = msg.createAttachmentPart(dh);
(Here I get the Fatal server Error => NullPointerException)
attachment.setContentId("attached_image");
msg.addAttachmentPart(attachment);
msg.saveChanges();
URL endpoint = new
URL("http://localhost:9090/RKO/services/zmogljivost?method=stevilo&str=test");
SOAPMessage response = con.call(msg, endpoint);
con.close(); -
Extract all attachments from .eml file
Hi
I have a .eml file saved to disk.
I want to extract all attachments that it contains into separate files.
Can anyone help me regarding this issue?
ThanksHi,
Did you had already success extracting the attachments from .eml File?
I'm also looking how to do this, but have not much success yet.
Thank you,
Stefan -
How can I extract all attachments together in office365 email?
How can I extract all attachments together in office365 email?
There is no build-in feature in Outlook 2013. However, we can accomplish that via coding VBA.
Here is a simple I may provide:
http://stackoverflow.com/questions/15531093/outlook-vba-macro-to-save-attachments-to-a-folder-and-rename-them
Programming/Code related questions should really be posed in one of the following forums:
Outlook for Developers
http://social.msdn.microsoft.com/Forums/en-US/outlookdev
Microsoft Office Programming
http://answers.microsoft.com/en-us/office/forum/customize?page=1&tab=all&tm=1361680524815
Tony Chen
TechNet Community Support -
Attachments help - C# using Obect API
I'm in my first attempt at integrating GW functionality into a C# application. I am not an expert C# programmer either. Thus far I've been successful at getting logged into GW, creating a new mail message and sending it successfully. However adding code to attach a file to my message returns an exception from the GroupwareTypeLibrary with the unhelpful error message "Unknown Error". Below is my code. If I comment out the line:
objMessage.Attachments.Add("c:\reg.log",1,"reg.log ");
the program runs successfully, happily sending my mail to the recipent mailbox. I know the c:\reg.log file exists and I have permissions to it.
Any advice as to what I'm doing wrong would be of tremendous help, as I've already search and cruised all the forums on GW API I can find to no avail. Running GW 7.03 I think on client and server side.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using GroupwareTypeLibrary;
namespace GWEmailTest
class Program
public static void Main()
GroupwareTypeLibrary.Application objApplication = new GroupwareTypeLibrary.Application();
GroupwareTypeLibrary.Account objAccount;
GroupwareTypeLibrary.Messages objMessages;
GroupwareTypeLibrary.Message objMessage;
GroupwareTypeLibrary.Folder objMailBox;
GroupwareTypeLibrary.Recipients objRecipients;
GroupwareTypeLibrary.Recipient objRecipient;
objAccount = objApplication.Login("dpuls", "", "password", "", "");
objMailBox = objAccount.MailBox;
objMessages = objMailBox.Messages;
objMessage = objMessages.Add("GroupwareTypeLibrary.Message",4," ");
objRecipients = objMessage.Recipients;
objRecipient = objRecipients.Add("dpuls","","");
objMessage.Subject.PlainText = "Here's the message from C#!.";
objMessage.BodyText.PlainText = "Here's the report you wanted.";
objMessage.Attachments.Add("c:\reg.log",1,"reg.log ");
objMessage.Send();Markus,
Thanks so much for your quick reply. I appreciate your willingness to help me overcome my ignorance. Here's what I found:
objMessage = objMessages.Add("GW.MESSAGE.MAIL", 4);
results in a C# compiler error "no overload method for 'add' requires '2' arguments". This tells me the third paramater is required for the GroupwareTypeLibary COM object, so I added the third null parameter back in, eliminating the compiler error. Then I still got the same "unknown error" exception back from the COM library as before.
So I went back to my shotgun approach of trying variations on parameter passing (instance variables instead of literals, etc). I noticed at one point when I tried another test file that I got a compiler error on a string literal of the path\filename "c:\csharptest.txt". Aha, says I ......
To make a long story short, by happenstance, my "c:\reg.log" parameter gets read in C# as containing an escape sequence reference, i.e. "\r" and when I changed to another test file it read "c:\csharptest.txt" as an INVALID escape sequence "\c". The fix then was to correct the problem of the reading of escape sequences in my string literal by changing my line of code to :
objMessage.Attachments.Add(@"c:\reg.log","1","");
Problem solved! Thanks again for your help.
dennis puls
Originally Posted by Markus Colorado
I suppose the way you're adding a draft message to the collection is false.
>> objMessages = objMailBox.Messages;
>> objMessage = objMessages.Add("GroupwareTypeLibrary.Message",4," ");
The function "Add()" takes only 2 parameters, 'ClassName' + 'ObjType'.
'ClassName' stands for the sort/subtype of message you'd like to create.
'ObjType' stands for 'draft' or 'personal'
Try the following:
objMessages = objMailBox.Messages;
objMessage = objMessages.Add("GW.MESSAGE.MAIL", 4);
The rest should be fine; the code for adding the attachment seems OK.
Markus
"dpuls" <[email protected]> schrieb im Newsbeitrag
news:[email protected]...
>
> I'm in my first attempt at integrating GW functionality into a C#
> application. I am not an expert C# programmer either. Thus far I've
> been successful at getting logged into GW, creating a new mail message
> and sending it successfully. However adding code to attach a file to my
> message returns an exception from the GroupwareTypeLibrary with the
> unhelpful error message "Unknown Error". Below is my code. If I
> comment out the line:
> objMessage.Attachments.Add("c:\reg.log",1,"reg.log ");
>
> the program runs successfully, happily sending my mail to the recipent
> mailbox. I know the c:\reg.log file exists and I have permissions to
> it.
>
> Any advice as to what I'm doing wrong would be of tremendous help, as
> I've already search and cruised all the forums on GW API I can find to
> no avail. Running GW 7.03 I think on client and server side.
>
> ****************************
> using System;
> using System.Collections.Generic;
> using System.Text;
> using System.IO;
> using GroupwareTypeLibrary;
>
> namespace GWEmailTest
> {
> class Program
> {
> public static void Main()
> {
> GroupwareTypeLibrary.Application objApplication = new
> GroupwareTypeLibrary.Application();
> GroupwareTypeLibrary.Account objAccount;
> GroupwareTypeLibrary.Messages objMessages;
> GroupwareTypeLibrary.Message objMessage;
> GroupwareTypeLibrary.Folder objMailBox;
> GroupwareTypeLibrary.Recipients objRecipients;
> GroupwareTypeLibrary.Recipient objRecipient;
>
> objAccount = objApplication.Login("dpuls", "", "password", "",
> "");
> objMailBox = objAccount.MailBox;
> objMessages = objMailBox.Messages;
> objMessage = objMessages.Add("GroupwareTypeLibrary.Message",4," ");
> objRecipients = objMessage.Recipients;
> objRecipient = objRecipients.Add("dpuls","","");
> objMessage.Subject.PlainText = "Here's the message from C#!.";
> objMessage.BodyText.PlainText = "Here's the report you wanted.";
> objMessage.Attachments.Add("c:\reg.log",1,"reg.log ");
> objMessage.Send();
> }
> }
> }
> ****************************
>
>
> --
> dpuls
> ------------------------------------------------------------------------
> dpuls's Profile: NOVELL FORUMS - View Profile: dpuls
> View this thread: Attachments help - C# using Obect API - NOVELL FORUMS
> -
How to deal with SOAP attachments?
Is there any information available on how to work with SOAP attachments? I am looking
for a feature similar to what is available in other products where you can take a
byte[] and map to image/jpg, application/octet-stream, etc... and have the tool create
the appropriate message formats. How would I do this using WL Workshop? I could
not find anything in the docs... is this supported?
Thanks,
BobEasiest thing is to encode the contents of the binary object in the XML
message as you suggest.
I'd like to hear more about what you are trying to do as well -- we're
planning on adding support for attachments in the next release, and I'd like
to make sure we do it in a way that meets your needs.
-C
"Bob Hayden" <[email protected]> wrote in message
news:[email protected]...
>
I am evaluating the capability of returning and consuming image/fileattachments through
a web service. This is one of our high priority integration requirementsand must
be available somehow through the framework we choose. Other productshave ways
to do this through an IDE... if WorkShop is not going to directly supportthis then
does anyone have any suggestions or examples on how this can be done in away that
is still intuitive for a WorkShop user (in other words without rolling upyour sleeves
and digging into JAX-RPC)? I suppose one could base64 it and add it tothe WorkShop-generated
message as a String using the return XML map, but I would prefer toinvestigate a
more standards-based approach.
Is it just me or does the lack of support for SOAP attachments seem to bea serious
missing piece from WL Workshop?
-Bob
"Raj Alagumalai" <[email protected]> wrote:
Bob,
WebLogic Workshop does not currently support SOAP attachments. However,
please note
that if you are developing your Web services using the APIs and services
provided
by J2EE and WebLogic Server directly, WebLogic Server does support SOAP
attachments.
Please refer to the following document for more Workshop FAQ's
http://dev2dev.bea.com/resourcelibrary/faqdetail.jsp?productType=weblogic+w
orkshop&highlight=faq
>>
Thanks
Raj Alagumalai
WebLogic Workshop Support
"Bob Hayden" <[email protected]> wrote:
Is there any information available on how to work with SOAP attachments?
I am looking
for a feature similar to what is available in other products where youcan
take a
byte[] and map to image/jpg, application/octet-stream, etc... and havethe
tool create
the appropriate message formats. How would I do this using WL Workshop?
I could
not find anything in the docs... is this supported?
Thanks,
Bob -
How to pass SOAP Attachments with JAX-RPC Web Service
I'm confused...
This sample shows how to send/receive SOAP attachments by using the JAX-RPC Handler mechanism. Can somebody confirm if this is the preferred way to do this. I've seen an example wich does something like:
public interface AttachmentService extends Remote {
public String storeDocumentService(javax.activation.DataHandler dh, String filename) throws RemoteException;
}and then uses JAX-RPC utilities to create wsdl, stubs and stuff. Does this have the same result, as what the OTN example shows (from an architecture perspective?
Thx,
Jan.Well, how an attachment is processed depends on your application logic...if your application logic requires to processing attachments and verify it before processing the SOAP message, handlers could be better option.
If you need to process the attachment while processing the SOAP message, you can do it in the service implementation class.
In both the cases you need to get access to SOAPMessage object and from there get the attachments with getAttachments method. -
Mapping DataHandler for SOAP attachments
Hi all.
I'm working on a web service that uses SOAP attachments in WebLogic Workshop 8.1,
but I'm having a bit of trouble testing. When I try to access the web service
using the auto-generated client jar provided by workshop, I get the following
error:
java.rmi.RemoteException: web service invoke failed; nested exception is:
javax.xml.soap.SOAPException: failed to serialize xml:weblogic.xml.sche
ma.binding.SerializationException: mapping lookup failure. class=class javax.act
ivation.DataHandler class context=TypedClassContext{schemaType=['http://www.w3.o
rg/2001/XMLSchema']:base64Binary}
I was under the impression that the DataHandler mapping was handled by BEA. Must
I manually map the type in order to use SOAP attachments, or am I missing another
vital step?
I've attached the WSDL file for this service. Thanks.
-Brian
[WS_Import.wsdl]Hi Brian,
I just created a .jws, client jar and standalone JAX-RPC static stub client, using
the WSDL you attached. Everything seems to work in WLS 8.1 SP2. Is this the version
you're using? I have attached a zip containing the static JAX-RPC static stub
client, and the .jws. To test it in the WLW IDE, you'll need to create the following
directories, in the WebLogic Server domain directory you use for WLW:
DCTMWebServices/attachments
The client just sends the certificate.war file, in the DataHandler dhContent argument.
This file is located in the domain directory, you use for WLW. The .jws saves
the attachment into the DCTMWebServices/attachments directory.
Here's the command line I use to run the standalone client:
c:\bea\home1\jdk141_05\jre\bin\java -classpath classes;lib\WS_Import.jar;C:\bea\home1\weblogic\platform81sp2\server\lib\webserviceclient+ssl.jar
-Dweblogic.webservice.verbose=true -Dweblogic.webservice.binding.verbose=true
DTCMWebServices.consumers.standalone.stub.WLWClient 2>stderr.out>stdout.out
Regards,
Mike Wooten
"Brian McLoughlin" <[email protected]> wrote:
>
>
>
Hi all.
I'm working on a web service that uses SOAP attachments in WebLogic Workshop
8.1,
but I'm having a bit of trouble testing. When I try to access the web
service
using the auto-generated client jar provided by workshop, I get the following
error:
java.rmi.RemoteException: web service invoke failed; nested exception
is:
javax.xml.soap.SOAPException: failed to serialize xml:weblogic.xml.sche
ma.binding.SerializationException: mapping lookup failure. class=class
javax.act
ivation.DataHandler class context=TypedClassContext{schemaType=['http://www.w3.o
rg/2001/XMLSchema']:base64Binary}
I was under the impression that the DataHandler mapping was handled by
BEA. Must
I manually map the type in order to use SOAP attachments, or am I missing
another
vital step?
I've attached the WSDL file for this service. Thanks.
-Brian[brian2.zip] -
I have to implement a File Transfer Service from one application to the other application. Initially I thought to do it with socket programming. In that case I have to take care of all the details. Then I decided to use SOAP-attachments to transfer the files. I want to send the files as the attachments to a SOAP message, so that I need not do the low level stuff. But, I am not sure which is the best solution. The files which I send are very big like 10MB or 20MB. Is it good to send them as an attachments to SOAPMessage(Using JAXM) or to go for socket programming. Does JAXM support transfer of big files? Or, if you know any other better solution for transfer of files from application to application please suggest me.
Seenu.Hi, did you ever get a response to your question or figure it out on your own? I'm about to decide the same thing and was trying to find information on large attachments to SOAP messages and whether it's a good idea or not. Specifically, I'm wondering if these large files are read completely into memory at any point or if the API is smart enough to cache...
-
DIME format for handling SOAP attachments
Hi all,
There is a proposal (I think by Microsoft) called the Direct Internet Message Encapsulation (DIME) format to handle SOAP attachments. This is a binary format which defines how to construct a single message with multiple payloads and it is suppose to be more efficient that MIME especially for large attachments.
Does anybody know the status of this proposal?
Thanks,
KenHi, I'm also looking for a DIME java implementation,
let me know if you find something
maybe we will develop it ourselves -
Does anyone know of documentation that states what the maximum suggested SOAPBody size is before one should begin using a SOAP Attachment?
thanks!Check this site:
http://www.w3.org/TR/SOAP-attachments.html#MultipartRelated
I am not sure if this is what you are referring to. I guess you may want to click the RFC specification links too. -
2 questions really:
1) Is there a way to define soap attachments in a WSDL? How? Can I just use wsdlc then?
2) Is there a way to access SOAP attachments if the WSDL doesn't describe them? Would I do this via a SOAP handler? Or is there another way?Hi,
can you check the wsdlLocation attribute of the @WebService annotation in your ejb endpoint impl, its name should be same with the wsdl in the EJB-JAR.
alternatively, you can modify the wsdl name in jar:/META-INF/wsdls/XXX.wsdl to allow it same with the attribute.
HTH,
Kevin
Maybe you are looking for
-
I am trying to set up a mail rule that triggers an Applescript. The Applescript will open all attachments with Preview in this case. I know the rule is being triggered because I have two actions for the rule, run the Applescript and Make a sound, and
-
Adf table columnStretching issue when using with in panel splitter
My Scenario is like this: I have used adf table with columnStretching to last column of table. And the table is placed at second facet of panelSplitter. On load it covers full area of second facet which is pretty good. When try to collapse panelSplit
-
HI ALL I have following requirement... In report I want to show the amount in Two currency's 1. Original Currency (Value posted in the System) 2. Base currency (Currency Depends on the Company code) Now I have 3 company code Compnay Code Currency
-
Invitations automatically added to iCal
Hi, I'm having a problem where incoming meeting invitation emails are being automatically added to iCal and then moved to the Trash folder. I already have Mail>Preferences>General>"Add invitations to iCal" set to "Never" and iCal>Preferences>Advanced
-
I'm trying to add my girlfriend as a contact. I put her AIM in the 'Add Buddy' box and she shows up for a little bit kinda flashing for about 3 seconds, and then goes away. What am I doing wrong?