在请求的时候出现问题,使用下面的方式请求就不会出现问题。
package webservice.client.utils; import java.util.Iterator; import java.util.Map; import javax.xml.namespace.QName; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpResponseException; import org.ksoap2.transport.HttpTransportSE; /** * Axis2 测试工具类 * @============================================= * * @author : Liuyc * @create : 2015-9-8 下午02:42:25 * @update : * @bolg : http://www.cnblogs.com/yuchuan/ * @csdn : http://blog.csdn.net/l_lycos * @E-mail : [email protected] * @desc : * * @============================================= */ public class Axis2tUtil { /** * 暂时为找到Axis2调用Axis1,先使用SAOP调用 * @param url * @param spaceName * @param method * @param map * @return */ public static String getResult(String url ,String spaceName, String method, Map<String, String> map){ SoapObject request = new SoapObject(url, method); Iterator it = map.keySet().iterator(); while(it.hasNext()){ String key = (String) it.next(); String value = map.get(key); request.addProperty(key, value); } SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10); envelope.bodyOut = request; envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE ht = new HttpTransportSE(url); String ret = null; try { ht.call(null, envelope); ret = String.valueOf(envelope.getResponse()); return ret; } catch (HttpResponseException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } catch (XmlPullParserException e1) { e1.printStackTrace(); } return null; } }
需要导入的jar包: ksoap2-3.4.0.jar
时间: 2024-10-25 04:24:42