android:为什么我执行一个函数时得到END_TAG错误,而它是其他工作的复制粘贴?

时间:2014-09-22 22:52:31

标签: java android ksoap2

当我调用WCF webservice时,我收到END_TAF错误。

我的堆栈错误是:

09-22 22:43:30.711: W/System.err(3338): org.xmlpull.v1.XmlPullParserException: expected: END_TAG {http://schemas.xmlsoap.org/soap/envelope/}Body (position:END_TAG </{http://schemas.xmlsoap.org/soap/envelope/}s:Fault>@1:802 in java.io.InputStreamReader@536f30c4) 
09-22 22:43:30.711: W/System.err(3338):     at org.kxml2.io.KXmlParser.require(KXmlParser.java:2046)
09-22 22:43:30.715: W/System.err(3338):     at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:138)
09-22 22:43:30.715: W/System.err(3338):     at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
09-22 22:43:30.715: W/System.err(3338):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
09-22 22:43:30.715: W/System.err(3338):     at org.tempuri.IAndroid.userPasswordExists(IAndroid.java:304)
09-22 22:43:30.715: W/System.err(3338):     at org.tempuri.IAndroid.getAllProductsAndOffers(IAndroid.java:50)
09-22 22:43:30.715: W/System.err(3338):     at info.android.AllFragment.onCreateView(AllFragment.java:48)
09-22 22:43:30.719: W/System.err(3338):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:829)
09-22 22:43:30.719: W/System.err(3338):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
09-22 22:43:30.719: W/System.err(3338):     at android.app.BackStackRecord.run(BackStackRecord.java:635)
09-22 22:43:30.719: W/System.err(3338):     at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397)
09-22 22:43:30.719: W/System.err(3338):     at android.app.Activity.performStart(Activity.java:5017)
09-22 22:43:30.723: W/System.err(3338):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
09-22 22:43:30.723: W/System.err(3338):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
09-22 22:43:30.723: W/System.err(3338):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
09-22 22:43:30.723: W/System.err(3338):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
09-22 22:43:30.723: W/System.err(3338):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-22 22:43:30.727: W/System.err(3338):     at android.os.Looper.loop(Looper.java:137)
09-22 22:43:30.727: W/System.err(3338):     at android.app.ActivityThread.main(ActivityThread.java:4745)
09-22 22:43:30.727: W/System.err(3338):     at java.lang.reflect.Method.invokeNative(Native Method)
09-22 22:43:30.727: W/System.err(3338):     at java.lang.reflect.Method.invoke(Method.java:511)
09-22 22:43:30.727: W/System.err(3338):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-22 22:43:30.727: W/System.err(3338):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-22 22:43:30.727: W/System.err(3338):     at dalvik.system.NativeStart.main(Native Method)
09-22 22:43:30.727: W/System.err(3338): java.lang.NullPointerException
09-22 22:43:30.731: W/System.err(3338):     at org.tempuri.IAndroid.getAllProductsAndOffers(IAndroid.java:50)
09-22 22:43:30.731: W/System.err(3338):     at info.android.AllFragment.onCreateView(AllFragment.java:48)
09-22 22:43:30.731: W/System.err(3338):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:829)
09-22 22:43:30.735: W/System.err(3338):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
09-22 22:43:30.735: W/System.err(3338):     at android.app.BackStackRecord.run(BackStackRecord.java:635)
09-22 22:43:30.735: W/System.err(3338):     at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397)
09-22 22:43:30.735: W/System.err(3338):     at android.app.Activity.performStart(Activity.java:5017)
09-22 22:43:30.735: W/System.err(3338):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
09-22 22:43:30.735: W/System.err(3338):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
09-22 22:43:30.735: W/System.err(3338):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
09-22 22:43:30.735: W/System.err(3338):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
09-22 22:43:30.739: W/System.err(3338):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-22 22:43:30.739: W/System.err(3338):     at android.os.Looper.loop(Looper.java:137)
09-22 22:43:30.739: W/System.err(3338):     at android.app.ActivityThread.main(ActivityThread.java:4745)
09-22 22:43:30.739: W/System.err(3338):     at java.lang.reflect.Method.invokeNative(Native Method)
09-22 22:43:30.739: W/System.err(3338):     at java.lang.reflect.Method.invoke(Method.java:511)
09-22 22:43:30.743: W/System.err(3338):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-22 22:43:30.743: W/System.err(3338):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-22 22:43:30.743: W/System.err(3338):     at dalvik.system.NativeStart.main(Native Method)

我正在调用一个测试用户和密码检查的函数。 我正在使用kso​​ap2的程序。代码是:

public static WcfResponse userPasswordExists(java.lang.String username,java.lang.String pwd){     字符串METHOD_NAME =“userPasswordExists”;     WcfResponse res = null;

try {           
    String SOAP_ACTION = Configuration.getWsSoapActionInit() + METHOD_NAME;

    SoapObject _client = new SoapObject(Configuration.getWsNameSpace(), METHOD_NAME);

    _client.addProperty("username", username);
    _client.addProperty("pwd", (pwd.equals(""))? null: pwd);


    SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    _envelope.dotNet = true;
    _envelope.bodyOut = _client;


    AndroidHttpTransport _ht = new AndroidHttpTransport(Configuration.getWsUrl());
    _ht.debug = false;

    _ht.call(SOAP_ACTION, _envelope);

    SoapObject _ret = (SoapObject) _envelope.getResponse();


    res = SoapMapping.ToWcfResponse(_ret);



} catch (Exception e) {

    e.printStackTrace();
    res = null;

}

return res;

}

我检查了everythinbg并且它是正确的,无论如何,代码是它正在工作的另一个人的副本,我不知道为什么这个。

我在WCF中的界面是:

public interface IAndroid
    {
        [OperationContract]
        WcfResponse EnviarCorreo(string To, string Asunto, string Body);

        [OperationContract]
        WcfResponse UserPasswordExists(string username, string pwd);

        [OperationContract]
        WcfResponse UserExists(string username);

        [OperationContract]
        WcfResponsePOList getAllProductsAndOffers(string province_id, string city_id, string code, string favoritos, string tipo);

        [OperationContract]
        WcfResponsePO getProductByCodigo(string codigo);

        [OperationContract]
        WcfResponsePO getOfferByCodigo(string codigo);

        [OperationContract]
        WcfResponseOK BuyProductOrOffer(string codigo, string tipo, string ip);

        [OperationContract]
        WcfResponsePOList getProductsByOfferCode(string codigo);

        [OperationContract]
        WcfResponseOK SetFavouriteOff(string codigo, string tipo);

        [OperationContract]
        WcfResponseOK SetFavouriteOn(string codigo, string tipo, string ip);

        [OperationContract]
        WcfResponseByteArray ImageToByteArray(string file);

        [OperationContract]
        WcfResponseDictionary getAllProvincies();

        [OperationContract]
        WcfResponseDictionary getAllCities();
    }

web.config是:

<?xml version="1.0" encoding="UTF-8"?>
<!--
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
  <appSettings>
    <add key="connection" value="Server=localhost;Port=3306;Database=david;Uid=root;Pwd=root;" />
    <add key="uploads" value="C:\Users\DMR\Google Drive\DESARROLLO\PHP\android\contents\img\uploads\" />
  </appSettings>

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:50:00" openTimeout="01:50:00" sendTimeout="01:50:00" receiveTimeout="01:50:00">
          <readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>

        <binding name="BasicHttpBinding_IAndroid" maxBufferSize="2147483647"
            maxReceivedMessageSize="2147483647" />

      </basicHttpBinding>
    </bindings>

    <client>
      <endpoint address="http://localhost/Android/Android.svc" binding="basicHttpBinding"
          bindingConfiguration="BasicHttpBinding_IAndroid" contract="IAndroid"
          name="BasicHttpBinding_IAndroid" />
    </client>

    <services>      
      <service behaviorConfiguration="ServiceBehavior" name="Android.Android">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="Android.IAndroid" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>      
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
          <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
        </behavior>
        <behavior name=" MyClient">
          <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
        </behavior>
      </serviceBehaviors>

    </behaviors>
  </system.serviceModel>
  <system.web>
    <compilation debug="true" />
  </system.web>
    <system.webServer>
        <directoryBrowse enabled="false" />
    </system.webServer>
</configuration>

代码中有什么问题?你需要更多东西吗?

也许我需要其他眼睛来帮助我

1 个答案:

答案 0 :(得分:0)

也许我需要把常量的内容,我解决了错误,在WCF中愚蠢我有函数声明UserPasswordExists和在ksoap中调用userPasswordExists

grrrrrrr