Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# KSOAP的WCF自托管服务(android)_C#_Android_Wcf_Web Services_Ksoap - Fatal编程技术网

C# KSOAP的WCF自托管服务(android)

C# KSOAP的WCF自托管服务(android),c#,android,wcf,web-services,ksoap,C#,Android,Wcf,Web Services,Ksoap,我已经有了我的android应用程序。到目前为止,我一直在使用KSOAP通信和一个web服务标准的asmx文件。一切正常,但一个月来我一直在尝试使用一个自托管的WCF服务为我的应用程序提供数据 我已经用WCF的配置做了所有的组合,但是仍然有些地方出了问题 伙计们,我需要一些简单的示例项目,比如KSOAP的HelloWorld WCF服务。配置端点、空间等。 非常感谢。 我花了很多时间在网上搜索,但我无法根据我找到的信息构建一个有效的服务 这是我第一次求助。。。 来自波兰的问候我也遇到了同样的问题

我已经有了我的android应用程序。到目前为止,我一直在使用KSOAP通信和一个web服务标准的asmx文件。一切正常,但一个月来我一直在尝试使用一个自托管的WCF服务为我的应用程序提供数据

我已经用WCF的配置做了所有的组合,但是仍然有些地方出了问题

伙计们,我需要一些简单的示例项目,比如KSOAP的HelloWorld WCF服务。配置端点、空间等。 非常感谢。

我花了很多时间在网上搜索,但我无法根据我找到的信息构建一个有效的服务

这是我第一次求助。。。
来自波兰的问候

我也遇到了同样的问题,并通过这种方式解决了问题(WCF绑定必须是basicHttpBinding,否则无法工作):

private静态最终字符串命名空间=”http://tempuri.org/";
私有静态字符串URL=“您的URL”;
私有静态最终字符串SOAP\u ACTION\u VALIDATION=“IValidateUser\u wcf/ValidateUser”;
私有静态最终字符串验证\u METHOD=“ValidateUser”;
公共布尔validateUser_WCF(字符串用户名、字符串密码){
SoapSerializationEnvelope=null;
SoapObject请求=null;
HttpTransportSE HttpTransportSE=null;
试一试{
请求=新的SoapObject(名称空间、验证方法);
request.addProperty(“用户名”,用户名);
request.addProperty(“密码”,password);
信封=新的SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(请求);
//////////////////////////////                               
//如果需要,可以在此处添加标题元素
元素[]头=新元素[1];
header[0]=new Element().createElement(名称空间_INFOCAD,“a1”);
header[0].addChild(Node.TEXT,“HeaderTextContent”);
envelope.headerOut=页眉;
//////////////////////////////                               
//第二个参数是超时:
httpTransportSE=
新的HttpTransportSE(URL+验证URI,10*10000);
httpTransportSE.debug=true;
httpTransportSE.setXmlVersionTag(
"");
调用(名称空间+SOAP\u操作\u验证,信封);
//如果响应是一个简单的文本结果,您可以调用
//SoapPrimitive,如果不是,则必须调用SoapObject
//结果并像xml文件一样在响应树中导航
SoapPrimitive结果=(SoapPrimitive)信封.getResponse();
//获取数据。
字符串textResult=result.toString();
Log.i(“textResult”,textResult);
返回true;
}捕获(例外e){
//TODO:处理异常
e、 printStackTrace();
}最后{
//在这里,您可以在日志中看到您发送的请求和收到的响应
Log.i(getClass().getSimpleName(),“requestDump:”+httpTransportSE.requestDump);
Log.i(getClass().getSimpleName(),“responseDump:”+httpTransportSE.responseDump);
}
返回false;
}

谢谢你回答Kinghomer。我的ksoap请求看起来很熟悉,我认为更大的问题是我的WCF服务,你能和我分享这个ksoap示例的C#WCF项目吗?你使用的是哪个ksoap版本?还有WCF绑定?ksoap2-android-assembly-3.0.0-jar-with-dependencies.jarksoap2-android-assembly-3.0.0-jar-with-dependencies.jar和HttpBinding,但我在WCF中仍然做了一些错误的事情。就像我写的,我对ksoap和asmx没有问题-我现在有一个完美的工作数据库应用程序,但我不想使用IIS服务器,我正在尝试将asmx重写为自托管WCF,但迄今为止没有成功:(我有3种不同的方式属性,哪一种是正确的?[WebInvoke(UriTemplate=“WelcomeUser”,Method=“POST”)][WebInvoke(Method=“POST”,BodyStyle=WebMessageBodyStyle.Wrapped,ResponseFormat=WebMessageFormat.Json)][WebInvoke(Method=“POST”,BodyStyle=WebMessageBodyStyle.Wrapped,ResponseFormat=WebMessageFormat.Xml]
private static final String NAMESPACE = "http://tempuri.org/";
private static String URL="your url";

private static final String SOAP_ACTION_VALIDATION = "IValidateUser_wcf/ValidateUser";
private static final String VALIDATION_METHOD = "ValidateUser";

public boolean validateUser_WCF(String username, String password){

    SoapSerializationEnvelope envelope = null;
    SoapObject request = null;
    HttpTransportSE httpTransportSE = null;

    try {
        request = new SoapObject(NAMESPACE, VALIDATION_METHOD);
        request.addProperty("username", username);
        request.addProperty("password", password);

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

        //////////////////////////////                               
        // here you can add a HEADER element if you want
        Element[] header = new Element[1];  

        header[0] = new Element().createElement(NAMESPACE_INFOCAD, "a1");                
        header[0].addChild(Node.TEXT, "HeaderTextContent");

        envelope.headerOut = header;
        //////////////////////////////                               

        // second parameter is timeout:
        httpTransportSE = 
            new HttpTransportSE(URL+VALIDATION_URI, 10*10000); 
        httpTransportSE.debug = true;
        httpTransportSE.setXmlVersionTag(
           "<?xml version=\"1.0\" encoding=\"utf-8\"?>");
        httpTransportSE.call(NAMESPACE+SOAP_ACTION_VALIDATION, envelope);

        // if response is a simple text result, you can call
        // SoapPrimitive, if not, you have to call SoapObject 
        // result and navigate in response's tree like an xml file
        SoapPrimitive result = (SoapPrimitive)envelope.getResponse();

        //To get the data.
        String textResult = result.toString();
        Log.i("textResult", textResult); 

        return true;

    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }finally{
       // here you can see in LOG what is request you send and what is response received
        Log.i(getClass().getSimpleName(),"requestDump : "+httpTransportSE.requestDump);
        Log.i(getClass().getSimpleName(),"responseDump : "+httpTransportSE.responseDump);
    }

    return false;
}