67,513
社区成员
发帖
与我相关
我的任务
分享
<s:element name="GetPictureResponse">
<s:complexType>
<s:sequence>
<s:element name="image" type="s:base64Binary"
xmime:expectedContentTypes="image/jpeg"/>
</s:sequence>
</s:complexType>
</s:element>
package com.googlepages.smallnest.facet;
public interface PictureService
{
public boolean uploadPicture(byte[] data,String name);
}
实现类:
package com.googlepages.smallnest.facet;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class PictureServiceImpl implements PictureService
{
public boolean uploadPicture(byte[] data, String name)
{
try
{
File image = new File(name);
image.createNewFile();
FileOutputStream out = new FileOutputStream(name);
out.write(data);
out.close();
System.out.println(image.getAbsolutePath());
}
catch (FileNotFoundException e)
{
return false;
}
catch (IOException e)
{
return false;
}
return true;
}
}
<beans>
<service xmlns="http://xfire.codehaus.org/config/1.0">
<name>PictureService</name>
<namespace>http://smallnest.googlepages.com/PictureService</namespace>
<serviceClass>com.googlepages.smallnest.facet.PictureService</serviceClass>
<implementationClass>com.googlepages.smallnest.facet.PictureServiceImpl</implementationC
lass>
<properties>
<property key="mtom-enabled">true</property>
</properties>
</service>
</beans>
package com.googlepages.smallnest.facet;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class FacetClient
{
public static void main(String[] args)
{
PictureServiceClient client = new PictureServiceClient();
PictureServicePortType pictureService = client.getPictureServiceHttpPort();
FileInputStream in;
try
{
in = new FileInputStream("girl.jpg");
byte[] data = new byte[in.available()];
in.read(data); //图片不大
in.close();
boolean b = pictureService.uploadPicture(data, "good.jpg");
System.out.println(b);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}