You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Newbie@Axis" <va...@gmail.com> on 2007/11/23 11:59:31 UTC

Axis - Using attachments

Hi ,
My requirement is to get a pdf from a service. The server sends a pdf and
the client has to store the same in the file system. But i am unable to save
the pdf in a location i want instead of the windows temp folder. Can some
one help me on this pls. I have attached the Service class, the client and
the wsdd.

// Service Class
public class PDFAttachmentsService {

	public DataHandler sendPdfs() throws MalformedURLException {

		String filename = "C:/EDDHome/1_52043_1.pdf";
		DataHandler dataHandler = new DataHandler(new FileDataSource(filename));

		return dataHandler;
	}
}

// Client Class
public class PDFAttachment {
	
	public static void main(String args[]) {
		try {
			Service service = new Service();

			Call call = (Call) service.createCall();

			call
				
.setTargetEndpointAddress("http://localhost:8080/axis/services/urn:PDFAttachmentsService");

			call.setOperationName(new QName("urn:PDFAttachmentsService",
					"sendPdfs")); 

			QName qnameAttachment = new QName("urn:PDFAttachmentsService",
					"DataHandler");
			call.registerTypeMapping(PDFAttachment.class, qnameAttachment,
					JAFDataHandlerSerializerFactory.class,
					JAFDataHandlerDeserializerFactory.class);

			call.setReturnType(qnameAttachment);

			Object ret = call.invoke(new Object[] {});

			if (null == ret) {
				System.out.println("Received null ");
				throw new AxisFault("", "Received null", null, null);
			}

			if (ret instanceof String) {
				System.out.println("Received problem response from server: "
						+ ret);
				throw new AxisFault("", (String) ret, null, null);
			}

			if (!(ret instanceof DataHandler)) {
				// The wrong type of object that what was expected.
				System.out.println("Received problem response from server:"
						+ ret.getClass().getName());
				throw new AxisFault("",
						"Received problem response from server:"
								+ ret.getClass().getName(), null, null);

			}

			DataHandler rdh = (DataHandler) ret;

			System.out.println("Received thro :" + rdh.getClass().getName());
		} catch (Exception e) {
			System.err.println(e);
			e.printStackTrace();
		}
	}
}

// WSDD file
<!-- This deploys PDF attachment service.  -->
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
xmlns:ns1="urn:PDFAttachmentsService" >
  <service name="urn:PDFAttachmentsService" provider="java:RPC" >
    <parameter name="className"
value="samples.pdfattachments.PDFAttachmentsService"/>
    <parameter name="allowedMethods" value="sendPdfs"/>
    <parameter name="dataHandler" type="ns1:DataHandler"/>    

 <typeMapping
deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory"
   languageSpecificType="java:javax.activation.DataHandler"
qname="ns1:DataHandler"
   
serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory" 
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
     />
  </service>

</deployment>

-- 
View this message in context: http://www.nabble.com/Axis---Using-attachments-tf4860902.html#a13910296
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis - Using attachments

Posted by "Vaibhav@Axis" <va...@gmail.com>.
Hi,
Thanks for your reply.... But i am using weblogic 8.1 SP6. My question is
how do i retain the name of the file while writing the file to the file
system ? I am able to write it with some dummy name of the file and not the
exact name which is in the source folder.


mgainty wrote:
> 
> In catalina.policy did you assign write permissions for the folder
> C:/EDDHome ?
> this is more tomcat setup than axis specific I would suggest asking the
> same
> question on Tomcat-user@jakarta.apache.org
> 
> M--
> ----- Original Message -----
> From: "Vaibhav@Axis" <va...@gmail.com>
> To: <ax...@ws.apache.org>
> Sent: Monday, November 26, 2007 10:16 AM
> Subject: Re: Axis - Using attachments
> 
> 
>>
>> Can anyone please help me ? I can write it to the directory i want but i
> am
>> unable to retain the name of the file.
>>
>>
>> Vaibhav@Axis wrote:
>> >
>> > Hi ,
>> > My requirement is to get a pdf from a service. The server sends a pdf
> and
>> > the client has to store the same in the file system. But i am unable to
>> > save the pdf in a location i want instead of the windows temp folder.
> Can
>> > some one help me on this pls. I have attached the Service class, the
>> > client and the wsdd.
>> >
>> > // Service Class
>> > public class PDFAttachmentsService {
>> >
>> > public DataHandler sendPdfs() throws MalformedURLException {
>> >
>> > String filename = "C:/EDDHome/1_52043_1.pdf";
>> > DataHandler dataHandler = new DataHandler(new
>> FileDataSource(filename));
>> >
>> > return dataHandler;
>> > }
>> > }
>> >
>> > // Client Class
>> > public class PDFAttachment {
>> >
>> > public static void main(String args[]) {
>> > try {
>> > Service service = new Service();
>> >
>> > Call call = (Call) service.createCall();
>> >
>> > call
>> >
>> >
> setTargetEndpointAddress("http://localhost:8080/axis/services/urn:PDFAttach
> mentsService");
>> >
>> > call.setOperationName(new QName("urn:PDFAttachmentsService",
>> > "sendPdfs"));
>> >
>> > QName qnameAttachment = new QName("urn:PDFAttachmentsService",
>> > "DataHandler");
>> > call.registerTypeMapping(PDFAttachment.class, qnameAttachment,
>> > JAFDataHandlerSerializerFactory.class,
>> > JAFDataHandlerDeserializerFactory.class);
>> >
>> > call.setReturnType(qnameAttachment);
>> >
>> > Object ret = call.invoke(new Object[] {});
>> >
>> > if (null == ret) {
>> > System.out.println("Received null ");
>> > throw new AxisFault("", "Received null", null, null);
>> > }
>> >
>> > if (ret instanceof String) {
>> > System.out.println("Received problem response from server: "
>> > + ret);
>> > throw new AxisFault("", (String) ret, null, null);
>> > }
>> >
>> > if (!(ret instanceof DataHandler)) {
>> > // The wrong type of object that what was expected.
>> > System.out.println("Received problem response from server:"
>> > + ret.getClass().getName());
>> > throw new AxisFault("",
>> > "Received problem response from server:"
>> > + ret.getClass().getName(), null, null);
>> >
>> > }
>> >
>> > DataHandler rdh = (DataHandler) ret;
>> >
>> > System.out.println("Received thro :" + rdh.getClass().getName());
>> > } catch (Exception e) {
>> > System.err.println(e);
>> > e.printStackTrace();
>> > }
>> > }
>> > }
>> >
>> > // WSDD file
>> > <!-- This deploys PDF attachment service.  -->
>> > <deployment xmlns="http://xml.apache.org/axis/wsdd/"
>> > xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
>> > xmlns:ns1="urn:PDFAttachmentsService" >
>> >   <service name="urn:PDFAttachmentsService" provider="java:RPC" >
>> >     <parameter name="className"
>> > value="samples.pdfattachments.PDFAttachmentsService"/>
>> >     <parameter name="allowedMethods" value="sendPdfs"/>
>> >     <parameter name="dataHandler" type="ns1:DataHandler"/>
>> >
>> >  <typeMapping
>> >
> deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory
> "
>> >    languageSpecificType="java:javax.activation.DataHandler"
>> > qname="ns1:DataHandler"
>> >
>> >
> serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory"
>> >     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
>> >      />
>> >   </service>
>> >
>> > </deployment>
>> >
>> >
>>
>> --
>> View this message in context:
> http://www.nabble.com/Axis---Using-attachments-tf4860902.html#a13951390
>> Sent from the Axis - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Axis---Using-attachments-tf4860902.html#a13967066
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis - Using attachments

Posted by Martin Gainty <mg...@hotmail.com>.
In catalina.policy did you assign write permissions for the folder
C:/EDDHome ?
this is more tomcat setup than axis specific I would suggest asking the same
question on Tomcat-user@jakarta.apache.org

M--
----- Original Message -----
From: "Vaibhav@Axis" <va...@gmail.com>
To: <ax...@ws.apache.org>
Sent: Monday, November 26, 2007 10:16 AM
Subject: Re: Axis - Using attachments


>
> Can anyone please help me ? I can write it to the directory i want but i
am
> unable to retain the name of the file.
>
>
> Vaibhav@Axis wrote:
> >
> > Hi ,
> > My requirement is to get a pdf from a service. The server sends a pdf
and
> > the client has to store the same in the file system. But i am unable to
> > save the pdf in a location i want instead of the windows temp folder.
Can
> > some one help me on this pls. I have attached the Service class, the
> > client and the wsdd.
> >
> > // Service Class
> > public class PDFAttachmentsService {
> >
> > public DataHandler sendPdfs() throws MalformedURLException {
> >
> > String filename = "C:/EDDHome/1_52043_1.pdf";
> > DataHandler dataHandler = new DataHandler(new FileDataSource(filename));
> >
> > return dataHandler;
> > }
> > }
> >
> > // Client Class
> > public class PDFAttachment {
> >
> > public static void main(String args[]) {
> > try {
> > Service service = new Service();
> >
> > Call call = (Call) service.createCall();
> >
> > call
> >
> >
setTargetEndpointAddress("http://localhost:8080/axis/services/urn:PDFAttach
mentsService");
> >
> > call.setOperationName(new QName("urn:PDFAttachmentsService",
> > "sendPdfs"));
> >
> > QName qnameAttachment = new QName("urn:PDFAttachmentsService",
> > "DataHandler");
> > call.registerTypeMapping(PDFAttachment.class, qnameAttachment,
> > JAFDataHandlerSerializerFactory.class,
> > JAFDataHandlerDeserializerFactory.class);
> >
> > call.setReturnType(qnameAttachment);
> >
> > Object ret = call.invoke(new Object[] {});
> >
> > if (null == ret) {
> > System.out.println("Received null ");
> > throw new AxisFault("", "Received null", null, null);
> > }
> >
> > if (ret instanceof String) {
> > System.out.println("Received problem response from server: "
> > + ret);
> > throw new AxisFault("", (String) ret, null, null);
> > }
> >
> > if (!(ret instanceof DataHandler)) {
> > // The wrong type of object that what was expected.
> > System.out.println("Received problem response from server:"
> > + ret.getClass().getName());
> > throw new AxisFault("",
> > "Received problem response from server:"
> > + ret.getClass().getName(), null, null);
> >
> > }
> >
> > DataHandler rdh = (DataHandler) ret;
> >
> > System.out.println("Received thro :" + rdh.getClass().getName());
> > } catch (Exception e) {
> > System.err.println(e);
> > e.printStackTrace();
> > }
> > }
> > }
> >
> > // WSDD file
> > <!-- This deploys PDF attachment service.  -->
> > <deployment xmlns="http://xml.apache.org/axis/wsdd/"
> > xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
> > xmlns:ns1="urn:PDFAttachmentsService" >
> >   <service name="urn:PDFAttachmentsService" provider="java:RPC" >
> >     <parameter name="className"
> > value="samples.pdfattachments.PDFAttachmentsService"/>
> >     <parameter name="allowedMethods" value="sendPdfs"/>
> >     <parameter name="dataHandler" type="ns1:DataHandler"/>
> >
> >  <typeMapping
> >
deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory
"
> >    languageSpecificType="java:javax.activation.DataHandler"
> > qname="ns1:DataHandler"
> >
> >
serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory"
> >     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> >      />
> >   </service>
> >
> > </deployment>
> >
> >
>
> --
> View this message in context:
http://www.nabble.com/Axis---Using-attachments-tf4860902.html#a13951390
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis - Using attachments

Posted by "Vaibhav@Axis" <va...@gmail.com>.
Can anyone please help me ? I can write it to the directory i want but i am
unable to retain the name of the file. 


Vaibhav@Axis wrote:
> 
> Hi ,
> My requirement is to get a pdf from a service. The server sends a pdf and
> the client has to store the same in the file system. But i am unable to
> save the pdf in a location i want instead of the windows temp folder. Can
> some one help me on this pls. I have attached the Service class, the
> client and the wsdd.
> 
> // Service Class
> public class PDFAttachmentsService {
> 
> 	public DataHandler sendPdfs() throws MalformedURLException {
> 
> 		String filename = "C:/EDDHome/1_52043_1.pdf";
> 		DataHandler dataHandler = new DataHandler(new FileDataSource(filename));
> 
> 		return dataHandler;
> 	}
> }
> 
> // Client Class
> public class PDFAttachment {
> 	
> 	public static void main(String args[]) {
> 		try {
> 			Service service = new Service();
> 
> 			Call call = (Call) service.createCall();
> 
> 			call
> 				
> .setTargetEndpointAddress("http://localhost:8080/axis/services/urn:PDFAttachmentsService");
> 
> 			call.setOperationName(new QName("urn:PDFAttachmentsService",
> 					"sendPdfs")); 
> 
> 			QName qnameAttachment = new QName("urn:PDFAttachmentsService",
> 					"DataHandler");
> 			call.registerTypeMapping(PDFAttachment.class, qnameAttachment,
> 					JAFDataHandlerSerializerFactory.class,
> 					JAFDataHandlerDeserializerFactory.class);
> 
> 			call.setReturnType(qnameAttachment);
> 
> 			Object ret = call.invoke(new Object[] {});
> 
> 			if (null == ret) {
> 				System.out.println("Received null ");
> 				throw new AxisFault("", "Received null", null, null);
> 			}
> 
> 			if (ret instanceof String) {
> 				System.out.println("Received problem response from server: "
> 						+ ret);
> 				throw new AxisFault("", (String) ret, null, null);
> 			}
> 
> 			if (!(ret instanceof DataHandler)) {
> 				// The wrong type of object that what was expected.
> 				System.out.println("Received problem response from server:"
> 						+ ret.getClass().getName());
> 				throw new AxisFault("",
> 						"Received problem response from server:"
> 								+ ret.getClass().getName(), null, null);
> 
> 			}
> 
> 			DataHandler rdh = (DataHandler) ret;
> 
> 			System.out.println("Received thro :" + rdh.getClass().getName());
> 		} catch (Exception e) {
> 			System.err.println(e);
> 			e.printStackTrace();
> 		}
> 	}
> }
> 
> // WSDD file
> <!-- This deploys PDF attachment service.  -->
> <deployment xmlns="http://xml.apache.org/axis/wsdd/"
> xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
> xmlns:ns1="urn:PDFAttachmentsService" >
>   <service name="urn:PDFAttachmentsService" provider="java:RPC" >
>     <parameter name="className"
> value="samples.pdfattachments.PDFAttachmentsService"/>
>     <parameter name="allowedMethods" value="sendPdfs"/>
>     <parameter name="dataHandler" type="ns1:DataHandler"/>    
> 
>  <typeMapping
> deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory"
>    languageSpecificType="java:javax.activation.DataHandler"
> qname="ns1:DataHandler"
>    
> serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory" 
>     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
>      />
>   </service>
> 
> </deployment>
> 
> 

-- 
View this message in context: http://www.nabble.com/Axis---Using-attachments-tf4860902.html#a13951390
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org