调用Web服务时出现异常

时间:2015-10-27 23:26:53

标签: android android-ksoap2

我正在尝试调用发送SOAP信封的Web服务,但我收到此错误:“java.lang.IllegalStateException:目标主机不能为null,或者在参数中设置.signal = null,host = null,路径= answerIden“

可能是什么问题?它与我用来调用它的方式有关吗?

这就是我所说的:

public static Boolean sendAnswers(String ticket, TdcSystem system) {
    try {
        SoapObject request = new SoapObject(TdcService.NAMESPACE, TdcService.METHOD_NAME[TdcService.TipoMetodo.ANSWER_IDEN.getValue()]);

        SoapSerializationEnvelope sobre = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        sobre.encodingStyle = SoapSerializationEnvelope.ENC;
        sobre.dotNet = false;
        sobre.implicitTypes = true;
        sobre.setOutputSoapObject(request);

        HttpTransportSE transporte = new HttpTransportSE(TdcService.URL);

        String xml = buildXmlRequest(ticket, system);

        SoapObject response = (SoapObject)sobre.getResponse();

        HttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(TdcService.METHOD_NAME[TdcService.TipoMetodo.ANSWER_IDEN.getValue()]);

        StringEntity se = new StringEntity(xml, HTTP.UTF_8);
        se.setContentType("text/xml");
        httpPost.addHeader("", TdcService.METHOD_NAME[TdcService.TipoMetodo.ANSWER_IDEN.getValue()]);

        httpPost.setEntity(se);
        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity resEntity = httpResponse.getEntity();

        return true;

    } catch (Exception e) {
        Auditing.LogError(e);
        return false;
    }
}

你能指出我正确的方向吗?

您要知道,我必须调用http://190.12.95.42/tdc/ServiceTDC/TDC.php服务的answerIden方法,并且TdcService定义如下:

package cl.virtualice.tdc.helpers;

/**
 * Created by Jaime on 24-10-2015.
 */
public class TdcService {
    public enum TipoMetodo {
        ANSWER_IDEN(0), CHECK_IDEN(1), CHECK_3G(2), RAN(3);

        private int _value;

        TipoMetodo(int Value) {
            this._value = Value;
        }

        public int getValue() {
            return _value;
        }

        public static TipoMetodo fromInt(int i) {
            for (TipoMetodo b : TipoMetodo .values()) {
                if (b.getValue() == i) { return b; }
            }
            return null;
        }
    }

    public static final String NAMESPACE = "urn:Configurationwsdl";
    public static final String URL="http://190.12.95.42/tdc/ServiceTDC/TDC.php";
    public static final String[] METHOD_NAME = {"answerIden", "checkiDen", "check3G", "RAN"};
    public static final String[] SOAP_ACTION = {"urn:Configurationwsdl#answerIden", "urn:Configurationwsdl#checkiDen", "urn:Configurationwsdl#check3G", "urn:Configurationwsdl#RAN"};
}

0 个答案:

没有答案