1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 package sample.mtom.service;
20 
21 import java.io.File;
22 import java.io.FileOutputStream;
23 
24 import javax.activation.DataHandler;
25 
26 import org.apache.ws.axis2.mtomsample.AttachmentResponse;
27 import org.apache.ws.axis2.mtomsample.AttachmentType;
28 import org.w3.www._2005._05.xmlmime.Base64Binary;
29 
30 /**
31  * MTOMServiceSkeleton java skeleton for the axisService
32  */
33 public class MTOMSampleSkeleton {
34 
35 	/**
36 	 * Auto generated method signature
37 	 *
38 	 * @param param0
39 	 * @throws Exception
40 	 *
41 	 */
attachment( org.apache.ws.axis2.mtomsample.AttachmentRequest param0)42 	public org.apache.ws.axis2.mtomsample.AttachmentResponse attachment(
43 			org.apache.ws.axis2.mtomsample.AttachmentRequest param0)
44 			throws Exception
45 
46 	{
47 		AttachmentType attachmentRequest = param0.getAttachmentRequest();
48 		Base64Binary binaryData = attachmentRequest.getBinaryData();
49 		DataHandler dataHandler = binaryData.getBase64Binary();
50 		File file = new File(
51 				attachmentRequest.getFileName());
52 		FileOutputStream fileOutputStream = new FileOutputStream(file);
53 		dataHandler.writeTo(fileOutputStream);
54 		fileOutputStream.flush();
55 		fileOutputStream.close();
56 
57 		AttachmentResponse response = new AttachmentResponse();
58 		response.setAttachmentResponse("File saved succesfully.");
59 		return response;
60 	}
61 
62 }
63