0

我正在尝试从我的 android 应用程序访问 php 网络服务。但它给出了这个错误`“预期:START_TAG {http://schemas.xmlsoap.org/soap/envelope/}信封(位置:START_TAG @11.43 in java io .inputStreamReader@4052d300) " . 这是我的 wsdl 文件

 <?xml version ='1.0' encoding ='UTF-8' ?>

<definitions 
name='product' 
targetNamespace='urn:PHP_SOAP_RPC' 
xmlns:tns='urn:PHP_SOAP_RPC' 
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' 
xmlns:xsd='http://www.w3.org/2001/XMLSchema' 
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' 
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' 
xmlns='http://schemas.xmlsoap.org/wsdl/'>  

 <message name='gettestRequest'>
<part name='id' type='xsd:string'/>
</message>
<message name='gettestRespones'>
<part name='id' type='xsd:string'/>
</message>

<portType name='productPortType'>               
    <operation name='gettest'> 
    <input message='tns:gettestRequest'/> 
    <output message='tns:gettestRespones'/> 
    </operation>         
</portType>
 <binding name='productBinding' type='tns:productPortType'> 


    <soap:binding style='rpc' 
    transport='http://schemas.xmlsoap.org/soap/http'/>      

    <operation name='gettest'> 
        <soap:operation soapAction='urn:xmethods-delayed-quotes#gettest'/> 
        <input> 
        <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' 
        encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> 
        </input> 
        <output> 
        <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' 
        encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> 
        </output> 
    </operation>    
</binding>

<service name='product'> 
    <port name='productPortType' binding='productBinding'> 
    <soap:address location='http://111.223.189.236/webservice/server1.php'/> 
    </port> 
</service> 

这是我的java文件

    String METHOD_NAME = "gettest";
    String NAME_SPACE = "urn:PHP_SOAP_RPC";
    String SOAP_ACTION = NAME_SPACE + METHOD_NAME;
    String URL = "http://111.223.189.236/webservice/shoppingcart.wsdl";


    SoapObject Request = new SoapObject(NAME_SPACE, METHOD_NAME);

    Request.addProperty("userId", "userId");


    SoapSerializationEnvelope soapEnvelop = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    // soapEnvelop.dotNet = true;
    soapEnvelop.setOutputSoapObject(Request);
    HttpTransportSE aht = new HttpTransportSE(URL);

    try {
        aht.call(SOAP_ACTION, soapEnvelop);
        SoapPrimitive resultString = (SoapPrimitive) soapEnvelop.getResponse();
        tv.setText(resultString.toString());

    } catch (Exception e) {
        tv.setText(e.toString());

}

这是我的 php 文件

<?php

echo "ccc";

 function gettest($id) {    
return $id;
  }
      $server1 = new SoapServer(null, array('uri'=> "urn://tyler/res"));
  $server1->addFunction("gettest"); 
  $server1->handle(); 

   ?>
4

1 回答 1

0

更改您的 url 和 delete.wsdl 然后尝试它 SoapPrimitive resultString = (SoapPrimitive) soapEnvelop.getResponse(); .not getresponse 使用 bodyin

于 2012-07-13T13:35:02.947 回答