「Java Web Services : Up and Running」という本に続いて、Java Web Services の学習を開始しました。本のいくつかのセクションで、著者はいくつかのxsd
部分について語っています。問題は、コードを試して を生成したときに、WSDL
それらの部分が得られないことです。
WS 実装の例を次に示します。
import java.awt.Image;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(serviceName = "SkiImageService")
// @HandlerChain(file = "../handlers/handler-chain.xml")
public class SkiImageService {
private static final String[] names = {"nordic.jpg", "tele.jpg", "alpine.jpg"};
private String default_key;
private Map<String, String> photos;
public SkiImageService() {
photos = new HashMap<String, String>();
photos.put("nordic", "nordic.jpg");
photos.put("alpine", "alpine.jpg");
photos.put("telemk", "telemk.jpg");
default_key = "nordic";
}
// Create a named image from the raw bytes.
private Image createImage(String name) {
byte[] bytes = getRawBytes(name);
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
Iterator iterators = ImageIO.getImageReadersByFormatName("jpeg");
ImageReader iterator = (ImageReader) iterators.next();
try {
ImageInputStream iis = ImageIO.createImageInputStream(in);
iterator.setInput(iis, true);
return iterator.read(0);
} catch (IOException e) {
System.err.println(e);
return null;
}
}
// Create a list of all available images.
private List<Image> createImageList() {
List<Image> list = new ArrayList<Image>();
Set<String> key_set = photos.keySet();
for (String key : key_set) {
Image image = createImage(key);
if (image != null) {
list.add(image);
}
}
return list;
}
// Returns one image given the image's name.
@WebMethod
public Image getImage(String name) {
return createImage(name);
}
// Returns a list of all available images.
@WebMethod
public List<Image> getImages() {
return createImageList();
}
// Read the bytes from the file for one image.
@SuppressWarnings("unused")
private byte[] getRawBytes(String name) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
String cwd = System.getProperty("user.dir");
String sep = System.getProperty("file.separator");
String base_name = cwd + sep + "jpegs" + sep;
String file_name = base_name + name + ".jpg";
FileInputStream in = new FileInputStream(file_name);
// Send default image if there's none with this name.
if (in == null) {
in = new FileInputStream(base_name + "nordic.jpg");
}
byte[] buffer = new byte[2048];
int n = 0;
while ((n = in.read(buffer)) != -1) {
out.write(buffer, 0, n); // append to ByteArrayOutputStream
}
in.close();
} catch (IOException e) {
System.err.println(e);
}
return out.toByteArray();
}
}
WSDL を見ると、次のものが見つかりません。
<xs:complexType name="getImagesResponse">
<xs:sequence>
<xs:element name="return" type="xs:base64Binary" minOccurs="0" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getImageResponse">
<xs:sequence>
<xs:element name="return" type="xs:base64Binary" minOccurs="0"></xs:element> </xs:sequence>
</xs:complexType>
XSD ファイル/パーツはどこにありますか?
よろしく、
ミック。