当前位置: 首页 > 知识库问答 >
问题:

Android KSOAP2错误以获取值

洪祺
2023-03-14

web服务获取值时出错。我一直在尝试,但没有成功。我用WCF做了webservice,实体框架.这台服务器运行良好。但我想连接并从Android手机中获得价值。

我的Android代码:

private final String NAMESPACE="http://tempuri.org/";
private final String SOAPACTION="http://tempuri.org/IService/GetValues";
private final String METHODNAME="GetTreatmentValues";

private final String URL="http://localhost:49674/Service.svc";

protected void onCreate(Bundle savedInstanceState){
Super.onCreate(savedInstanceState);setContentView(r.Layout.Menu);Button1.SetOnClickListener(new View.OnClickListener(){

@override
public void onClick(View v){

          SoapObject request = new SoapObject(NAMESPACE,METHODNAME);
          request.addProperty("value",1);

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

          HttpTransportSE aht = new HttpTransportSE(URL);
          aht.debug = true;
          text2.setText(aht.toString());
          //AndroidHttpTransport aht = new AndroidHttpTransport(URL);
          try {
              aht.call(SOAPACTION,sp);  //I have ERROR! no work.
              //SoapPrimitive resultstring = (SoapPrimitive)sp.getResponse();
              text1.setText("test");
              //text2.setText(resultstring.toString());
          } catch (Exception e) {
              // TODO: handle exception
              text2.setText("hata!");
          }           
                  }       
             });

我得到错误AHT.CALL(SOAPACTION,sp);text1从不设置“测试”我应该做什么。我不知道我错过了什么。多谢了。(使用KSOAP2.4)

共有2个答案

谷梁弘深
2023-03-14

我把我的webservice放入了ISS。我的链接是http://localhost:90/service.svc?wsdl在这个页面中,我看到了xml代码

 -<wsdl:binding name="BasicHttpBinding_IService" type="tns:IService">
   <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    wsdl:operation name="GetTreatmentValues">

     <soap:operation style="document"
     soapAction="http://tempuri.org/IService/GetTreatmentValues"/>


     -<wsdl:input>

     <soap:body use="literal"/>

     </wsdl:input>

     -<wsdl:output>

     <soap:body use="literal"/>

     </wsdl:output>

     </wsdl:operation>

我把这段代码写进Android应用程序

private final String NAMESPACE="http://tempuri.org/"; 
private final String SOAPACTION="http://tempuri.org/GetTreatmentValues"; 
private final String METHODNAME="GetTreatmentValues"; 


private final String URL="http://localhost:90/Service.svc?singleWsdl";

但我总是在这里出错:(:(

try {
              aht.call(SOAPACTION,sp);  //I have ERROR! no work.
              //SoapPrimitive resultstring = (SoapPrimitive)sp.getResponse();
              text1.setText("test");
              //text2.setText(resultstring.toString());
          } catch (Exception e) {
              // TODO: handle exception
              text2.setText("hata!");
          }          
柯天宇
2023-03-14

null

希望你能得到解决。

 类似资料:
  • 我无法恢复数据从我的Wordpress API与改造库。错误是:HTTP FAILED:java.net.未知主机异常:无法解决主机"app.divion.fr":没有地址与主机名关联 ApiClient: } API接口: 公共接口{ } 显示xml Thx;)

  • 所以,我从用户提示输入变量。如果变量小于0且大于10。如果用户输入

  • 在将新更新安装到Visual Studio后,我才开始出现此错误。出于某种原因,我的建筑现在都不会从詹金斯那里得到。已经做了几个小时了,似乎还不明白。 我从比特桶里取东西。 请帮助。 由工作区C:\Program Files(x86)\Jenkins\workspace\CA[WS-CLEANUP]中的计时器生成启动删除项目工作区。。。[WS-CLEANUP]已完成克隆远程Git存储库克隆存储库h

  • 试图找出我出错的原因。我的数字介于-1和1之间,但仍然有错误。 数学域错误 有什么想法吗? 谢谢

  • 问题内容: 我正在使用位于此处的教程:http : //addyosmani.github.io/backbone-fundamentals/#create- a-simple-web-server 并添加了以下代码。 在启动服务器后,我收到一条错误消息,指出访问时的错误,我只是想知道是否有人对这个错误了解很多,因为Express和Node对我来说是新的? 问题答案: 我认为您缺少路线,您需要定义

  • 我想从这个函数中获取星期几(星期一,星期二,...),该函数接收参数3 int,即年份、月份和日期,我已经尝试了Calendar和GregorianCalendar,但它仍然给我错误,例如,如果我今天通过日期(2017,11,04)它给我一周中第5天的结果,星期四是今天星期二,我给你留下代码 Log. i显示此消息: DiaSemana:5 dias:11 mes:4 año:2017