import com.fujitsu.uji.soap.SOAPCallFactory;
import com.fujitsu.uji.soap.ServiceCall;
import com.fujitsu.uji.soap.Response;
import com.fujitsu.uji.soap.Parameter;
import com.fujitsu.uji.soap.Parameters;
import com.fujitsu.uji.soap.SOAPMappingRegistry_Apache;
import com.fujitsu.uji.soap.QName_Apache;
import org.apache.soap.encoding.soapenc.BeanSerializer;
import org.apache.soap.Constants;
public void someMethod(DispatchContext context, MyDataBean dataBean) {
...
// 復帰値型を設定
Class[] paramTypes = new Class[]{String.class};
// メソッドのパラメタ型を設定
SomeClass someClass = new SomeClass();
Parameters params = new Parameters();
params.add("param1", String.class, "test");
params.add("param2", SomeClass.class, someClass);
// MappingRegistryの設定
SOAPMappingRegistry_Apache smr = new SOAPMappingRegistry_Apache();
BeanSerializer beanSer = new BeanSerializer();
smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName_Apache("urn:some-convert-namespace", "typename"),
SomeClass.class,
beanSer,
beanSer);
// CallFactoryの取得
String url = new String("http://some.host/service");
SOAPCallFactory callFactory=(SOAPCallFactory)context.getCallFactory(CallFactory.SOAP);
ServiceCall call = factory.getServiceCall("myservice");
// MappingRegistryの設定
call.setMappingRegistry(smr);
// サービスの呼び出し
Response resp = call.invoke(params);
// 復帰値を取得
Parameter ret = resp.getReturnValue();
String str = (String)ret.getValue();
...
}
|