0

PHPで作成されたWebサービスへのアクセスに問題があります。私は多くのコードを試しましたが、動作しない愚かなバグがあるかどうかわかりません。

PHPでページから呼び出しを行うと機能しますが、Android経由でアクセスすると機能しないため、ANDROIDでの呼び出しも機能するため、Webサービスは良いと思います。

エラーが発生する場所: transporte.call(SOAP_ACTION, エンベロープ,null);

エラーは次のとおりです。org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://www.w3.org/2003/05/soap-envelope}Envelope (position:START_TAG <definitions name='SMB_GestionBoda' targetNamespace='http://localhost/webservice/SMB_GestionBoda.wdsl'>@8:43 in java.io.InputStreamReader@405d9f50)

ありがとう。

WSDL:

<definitions 
    name='SMB_GestionBoda'
    targetNamespace='http://localhost/webservice/SMB_GestionBoda.wdsl'
    xmlns:tns='http://localhost/webservice/SMB_GestionBoda.wdsl'
    xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
    xmlns:soap12='http://schemas.xmlsoap.org/wsdl/soap12/'
    xmlns='http://schemas.xmlsoap.org/wsdl/'>   
<message name='GetProvidersRequest'>
    <part name='id_task' type='xsd:int'/>
    <part name='city' type='xsd:string'/>
</message>
<message name='GetProvidersResponse'>
    <part name='result'/>
</message>
<portType name='SMB_GestionBodaPortType'>
    <operation name='GetProviders'>
        <input message='tns:GetProvidersRequest'/>
        <output message='tns:GetProvidersResponse'/>
    </operation>
</portType>
<binding name='SMB_GestionBodaBinding' type='tns:SMB_GestionBodaPortType'>
    <soap:binding style='rpc'
        transport='http://schemas.xmlsoap.org/soap/http'/>
    <operation name='GetProviders'>
        <soap:operation soapAction='urn:localhost-SMB_GestionBoda#GetProviders'/>
        <input>
            <soap:body use='encoded' namespace='urn:localhost-SMB_GestionBoda'
            encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
        </input>
        <output>
            <soap:body use='encoded' namespace='urn:localhost-SMB_GestionBoda'
            encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
        </output>
    </operation>
</binding>
<service name='SMB_GestionBodaService'>
    <port name='SMB_GestionBodaPort' binding='SMB_GestionBodaBinding'>
        <soap:address location='http://localhost/webservice/GetProviders.php'/>
    </port>
</service>
</definitions>

アンドロイドコード:

//Constantes para la invocacion del web service
        final String NAMESPACE = "http://localhost/webservice/SMB_GestionBoda.wdsl";
        final String URL="http://192.168.0.10/webservice/SMB_GestionBoda.wdsl";
        final String METHOD_NAME = "GetProviders";
        final String SOAP_ACTION = "urn:localhost-SMB_GestionBoda#GetProviders";  

        /*Se crea un objeto SoapObject para poder realizar la peticion
        para consumir el ws SOAP. El constructor recibe
        el namespace. Por lo regular el namespace es el dominio 
        donde se encuentra el web service*/
        request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("id_task",0);
        request.addProperty("city","valencia");


        /*Se crea un objeto SoapSerializationEnvelope para serealizar la
        peticion SOAP y permitir viajar el mensaje por la nube
        el constructor recibe la version de SOAP*/
        envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
        envelope.dotNet = false; //se asigna true para el caso de que el WS sea de dotNet

        //Se envuelve la peticion soap
        envelope.setOutputSoapObject(request);

        //Objeto que representa el modelo de transporte
        //Recibe la URL del ws
        HttpTransportSE transporte = new HttpTransportSE(URL);
        transporte.debug=true;


        try {   
            System.setProperty("http.keepAlive", "false");
            //Hace la llamada al ws
            transporte.call(SOAP_ACTION, envelope,null);

            //Se crea un objeto SoapPrimitive y se obtiene la respuesta 
            //de la peticion
            resultsRequestSOAP = (SoapPrimitive)envelope.getResponse();
            //result = (SoapObject)envelope.bodyIn;

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            // TODO Auto-generated catch block
            Log.d("MI APP","dump : " + transporte.responseDump);
            e.printStackTrace();
        }

リクエスト ダンプ:

<v:Envelope 
xmlns:i="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:d="http://www.w3.org/2001/XMLSchema" 
xmlns:c="http://www.w3.org/2003/05/soap-encoding" 
xmlns:v="http://www.w3.org/2003/05/soap-envelope">
<v:Header />
<v:Body>
<n0:GetProviders id="o0" c:root="1" xmlns:n0="http://localhost/webservice/SMB_GestionBoda.wdsl">
<id_task i:type="d:int">0</id_task>
<city i:type="d:string">valencia</city>
</n0:GetProviders>
</v:Body>
</v:Envelope>

応答ダンプ:

    <?xml version="1.0" encoding="utf-8"?>
<definitions 
    name='SMB_GestionBoda'
    targetNamespace='http://localhost/webservice/SMB_GestionBoda.wdsl'
    xmlns:tns='http://localhost/webservice/SMB_GestionBoda.wdsl'
    xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
    xmlns:soap12='http://schemas.xmlsoap.org/wsdl/soap12/'
    xmlns='http://schemas.xmlsoap.org/wsdl/'>

<message name='GetProvidersRequest'>
    <part name='id_task' type='xsd:int'/>
    <part name='city' type='xsd:string'/>
</message>
<message name='GetProvidersResponse'>
    <part name='result'/>
</message>

<portType name='SMB_GestionBodaPortType'>
    <operation name='GetProviders'>
        <input message='tns:GetProvidersRequest'/>
        <output message='tns:GetProvidersResponse'/>
    </operation>
</portType>

<binding name='SMB_GestionBodaBinding' type='tns:SMB_GestionBodaPortType'>
    <soap:binding style='rpc'
        transport='http://schemas.xmlsoap.org/soap/http'/>
    <operation name='GetProviders'>
        <soap:operation soapAction='urn:localhost-SMB_GestionBoda#GetProviders'/>
        <input>
            <soap:body use='encoded' namespace='urn:localhost-SMB_GestionBoda'
            encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
        </input>
        <output>
            <soap:body use='encoded' namespace='urn:localhost-SMB_GestionBoda'
            encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
        </output>
    </operation>
</binding>

<service name='SMB_GestionBodaService'>
    <port name='SMB_GestionBodaPort' binding='SMB_GestionBodaBinding'>
        <soap:address location='http://localhost/webservice/GetProviders.php'/>
    </port>
</service>
</definitions>
4

1 に答える 1

0

URL を .wsdl ではなく拡張子 .asmx に変更します

于 2013-02-20T14:46:39.200 に答える