Ошибка TimeOut при подключении приложения Android к веб-сервису Asp.net - PullRequest
0 голосов
/ 25 января 2019

Добрый день. Я пытаюсь подключить приложение Android к локальному веб-сервису .net, и оно показывает мне исключение java.net.SocketTimeoutException. Веб-сервис доступен в сети, и я могу связаться со всей локальной сети.

Я впервые программирую на Android. Я использую библиотеку ksoap2 в Android Studio и думаю, что понимаю, что делаю (очевидно, нет). Веб-сервис получает 4 параметра и вставляет их в базу данных.

package com.amcspainfresh.amc_marcaje;

import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

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 java.net.URL;

public class MainActivity extends AppCompatActivity {

private EditText tcodbarr,tcalibre,tbultos;

//Informació Webservice

final String NAMESPACE = "http://tempuri.org/";
final String URL = "http://svf-ws.amc.lan/WebSite1/WebService.asmx";
final String METHOD_NAME = "PalletMarcadora";
final String SOAP_ACTION = "http://tempuri.org/PalletMarcadora";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


}




public void enviarWS (View view){

        tcodbarr=(EditText)findViewById(R.id.tcodbarr);
        tcalibre=(EditText)findViewById(R.id.tcalibre);
        tbultos=(EditText)findViewById(R.id.tbultos);

    final  AlertDialog ad=new AlertDialog.Builder(this).create();

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

      request.addProperty("usuario","usuario");
      request.addProperty("codbarr", tcodbarr.getText().toString());
      request.addProperty("bultos", tbultos.getText().toString());
      request.addProperty("calibre", tcalibre.getText().toString());


    SoapSerializationEnvelope envelope = new 
SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
        envelope.dotNet = true;

    HttpTransportSE ht = new HttpTransportSE(URL,3000000);
    try {
        ht.call(SOAP_ACTION, envelope);
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        String resultado=response.toString();
        Log.i("Resultado: ",resultado);
    }
    catch (Exception e)
    {
        e.printStackTrace();
        ad.setTitle("Errores");
        ad.setMessage(e.toString());
        ad.show();
    }

}

}

И это WSDL веб-службы:

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/">
            <wsdl:types>
            <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
            <s:element name="PalletMarcadora">
            <s:complexType>
            <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="usuario" type="s:string"/>
            <s:element minOccurs="0" maxOccurs="1" name="codbarr" type="s:string"/>
            <s:element minOccurs="1" maxOccurs="1" name="bultos" type="s:decimal"/>
            <s:element minOccurs="0" maxOccurs="1" name="calibre" type="s:string"/>
            </s:sequence>
            </s:complexType>
            </s:element>
            <s:element name="PalletMarcadoraResponse">
            <s:complexType>
            <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="PalletMarcadoraResult" type="s:string"/>
            </s:sequence>
            </s:complexType>
            </s:element>
            <s:element name="LoginInformix">
            <s:complexType>
            <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="usuario" type="s:string"/>
            <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
            </s:sequence>
            </s:complexType>
            </s:element>
            <s:element name="LoginInformixResponse">
            <s:complexType>
            <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="LoginInformixResult" type="s:string"/>
            </s:sequence>
            </s:complexType>
            </s:element>
            </s:schema>
            </wsdl:types>
            <wsdl:message name="PalletMarcadoraSoapIn">
            <wsdl:part name="parameters" element="tns:PalletMarcadora"/>
            </wsdl:message>
            <wsdl:message name="PalletMarcadoraSoapOut">
            <wsdl:part name="parameters" element="tns:PalletMarcadoraResponse"/>
            </wsdl:message>
            <wsdl:message name="LoginInformixSoapIn">
            <wsdl:part name="parameters" element="tns:LoginInformix"/>
            </wsdl:message>
            <wsdl:message name="LoginInformixSoapOut">
            <wsdl:part name="parameters" element="tns:LoginInformixResponse"/>
            </wsdl:message>
            <wsdl:portType name="WebServiceSoap">
            <wsdl:operation name="PalletMarcadora">
            <wsdl:input message="tns:PalletMarcadoraSoapIn"/>
            <wsdl:output message="tns:PalletMarcadoraSoapOut"/>
            </wsdl:operation>
            <wsdl:operation name="LoginInformix">
            <wsdl:input message="tns:LoginInformixSoapIn"/>
            <wsdl:output message="tns:LoginInformixSoapOut"/>
            </wsdl:operation>
            </wsdl:portType>
            <wsdl:binding name="WebServiceSoap" type="tns:WebServiceSoap">
            <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
            <wsdl:operation name="PalletMarcadora">
            <soap:operation soapAction="http://tempuri.org/PalletMarcadora" style="document"/>
            <wsdl:input>
            <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
            <soap:body use="literal"/>
            </wsdl:output>
            </wsdl:operation>
            <wsdl:operation name="LoginInformix">
            <soap:operation soapAction="http://tempuri.org/LoginInformix" style="document"/>
            <wsdl:input>
            <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
            <soap:body use="literal"/>
            </wsdl:output>
            </wsdl:operation>
            </wsdl:binding>
            <wsdl:binding name="WebServiceSoap12" type="tns:WebServiceSoap">
            <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
            <wsdl:operation name="PalletMarcadora">
            <soap12:operation soapAction="http://tempuri.org/PalletMarcadora" style="document"/>
            <wsdl:input>
            <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
            <soap12:body use="literal"/>
            </wsdl:output>
            </wsdl:operation>
            <wsdl:operation name="LoginInformix">
            <soap12:operation soapAction="http://tempuri.org/LoginInformix" style="document"/>
            <wsdl:input>
            <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
            <soap12:body use="literal"/>
            </wsdl:output>
            </wsdl:operation>
            </wsdl:binding>
            <wsdl:service name="WebService">
            <wsdl:port name="WebServiceSoap" binding="tns:WebServiceSoap">
            <soap:address location="http://svf-ws.amc.lan/WebSite1/WebService.asmx"/>
            </wsdl:port>
            <wsdl:port name="WebServiceSoap12" binding="tns:WebServiceSoap12">
            <soap12:address location="http://svf-ws.amc.lan/WebSite1/WebService.asmx"/>
            </wsdl:port>
            </wsdl:service>
            </wsdl:definitions>

Большое спасибо за помощь!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...