はい、可能です。あなたが見ることができるように、何のPropertyInfoオブジェクトは必要ありません
package soap.service.image;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
public class ImageSoapActivity extends Activity {
private static final String NAMESPACE = "http://image.webservice";
private static final String URL = "http://10.0.2.2:8080/images?wsdl";
private static final String METHOD_NAME = "getImage";
private static final String SOAP_ACTION = "http://image.webservice/getImage";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
System.out.println("****** RESULT: " + resultsRequestSOAP.toString());
} catch (Exception e) {
System.out.println("******* THERE WAS AN ERROR ACCESSING THE WEB SERVICE");
e.printStackTrace();
}
}
}
;)サービス側では、私は、JAX-WSを使用しています:ここで働いアンドロイドSOAPクライアントです。これが誰かを助けることを願っています。また、Jax-wsを使って石鹸サービスを構築している場合は、以下の要素を使用しない場合、アンドロイドで「ディスパッチメソッドを見つけることができません」という例外が発生することがわかりました。私のサービスエンドポイントインタフェースとサービス実装BeanのためのWebService注釈:あなたが見ることができるようにここではサービスエンドポイントインタフェースがある
package soap.service.sei;
import javax.jws.WebService;
// I get an error in android if I don't include these elements in the
// @WebService annotation
@WebService(name = "ImageSei", targetNamespace = "http://image.webservice")
public interface ImageSei {
public byte[] getImage();
}
ここでは私のサービス実装Beanが
package soap.service.impl;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.jws.WebService;
import soap.service.sei.ImageSei;
// I get an error in android if I don't include these elements in the
// @WebService annotation
@WebService(endpointInterface = "soap.service.sei.ImageSei", portName = "ImageWSPort",
serviceName = "ImageWSService", targetNamespace = "http://image.webservice")
public class ImageSib implements ImageSei {
@Override
public byte[] getImage() {
byte[] imageBytes = null;
try {
File imageFile = new File("C:\\images\\car.png");
BufferedImage img = ImageIO.read(imageFile);
ByteArrayOutputStream baos = new ByteArrayOutputStream(1000);
ImageIO.write(img, "png", baos);
baos.flush();
imageBytes = baos.toByteArray();
baos.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
System.out.println("Got request");
return imageBytes;
}
}
で、このサービスは、として画像を読み込み、一連のバイトをバイト配列としてアンドロイドデバイスに送ります。