0

解決済み

このエラーを解決しようとしていますが、「transport.call(SOAP_ACTION、envelope);」の理由がわかりません。常にエラーが発生します。私のWebサービスは非常にシンプルで、SoupUIでテストし、nusoapを使用してphpでビルドしました。誰かが助けてくれることを願っています。よろしくお願いします。

エラーの説明:オープン宣言void org.ksoap2.transport.HttpTransportSE.call(String soapAction、SoapEnvelope Envelope)はIOException、XmlPullParserExceptionをスローします

解像度; 「transport.call(SOAP_ACTION、envelope)」エラーを修正するには、2つのことを行う必要がありました。1ºこのコード行を使用しましたSystem.setProperty( "http.keepAlive"、 "false");これは、api <9の場合のksoap2の問題であり、その後、インターネット用のandroidマニフェストにアクセス許可を追加したところ、機能しました。

これは私のAndroidコードです

//SOUP web service
private static final String SOAP_ACTION = "urn:primeFactorization#doCalc";
private static final String METHOD_NAME = "doCalc";
private static final String NAMESPACE = "urn:primeFactorization";
private static final String URL = "http://192.168.1.33/androidWebService/calcNumber.php";

//webServerに接続します

public SoapObject getPrimeFactorization(String number) throws Exception{
    System.setProperty("http.keepAlive", "false");//--> This resolved my problem
    SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME);


    request.addProperty("number",number);       
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    //envelope.dotNet = true;
    envelope.setOutputSoapObject(request);

    HttpTransportSE transport = new HttpTransportSE(URL);
    try{
    transport.call(SOAP_ACTION, envelope); //This is were i get the error:S<----
    Log.v("TEST","runs ok attributes "+envelope.getResponse().toString());
    }catch (Exception e) {
        e.printStackTrace();
    }

    return (SoapObject) envelope.getResponse();
}

//そして私のWebサービスWSDL

<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:primeFactorization" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:primeFactorization">
<types>
    <xsd:schema targetNamespace="urn:primeFactorization">
        <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
        <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
    </xsd:schema>
</types>
<message name="doCalcRequest">
    <part name="number" type="xsd:string"/>
</message>
<message name="doCalcResponse">
    <part name="return" type="xsd:string"/>
</message>
<portType name="primeFactorizationPortType">
    <operation name="doCalc">
        <documentation>Calculates the prime factorial of a given number</documentation>
        <input message="tns:doCalcRequest"/>
        <output message="tns:doCalcResponse"/>
    </operation>
</portType>
<binding name="primeFactorizationBinding" type="tns:primeFactorizationPortType">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="doCalc">
        <soap:operation soapAction="urn:primeFactorization#doCalc" style="rpc"/>
        <input>
        <soap:body use="encoded" namespace="urn:primeFactorization" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output>
            <soap:body use="encoded" namespace="urn:primeFactorization" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
    </operation>
</binding>
<service name="primeFactorization">
    <port name="primeFactorizationPort" binding="tns:primeFactorizationBinding">
        <soap:address location="http://192.168.1.33/androidWebService/calcNumber.php"/>
    </port>
</service>

4

2 に答える 2

1

私の「transport.call(SOAP_ACTION、エンベロープ)」エラーを修正するために、私は 2 つのことをしなければなりませんでした。 Android api < 9のksoap2の問題であり、その後、インターネット用のAndroidマニフェストにアクセス許可を追加したところ、機能しました。

于 2013-11-19T17:49:28.353 に答える
1

代わりにこれを使用して、リクエストの結果を取得します。

SoapObject result = (SoapObject)envelope.bodyIn;
Log.v("TEST","runs ok attributes "+result.getProperty(0).toString());
于 2012-12-17T19:42:55.940 に答える