Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.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# 如何在android中获取wcf服务的自定义消息头_C#_Android_Web Services_Wcf_Custom Headers - Fatal编程技术网

C# 如何在android中获取wcf服务的自定义消息头

C# 如何在android中获取wcf服务的自定义消息头,c#,android,web-services,wcf,custom-headers,C#,Android,Web Services,Wcf,Custom Headers,我正在使用此->>我认为您没有正确设置标题。我看不出您在哪里设置标题[0]。 也许你必须插入这行代码 envelope.headerOut = header; I-face:类型不匹配:无法从元素转换到元素[]。能否尝试这行代码信封。headerOut=header;是的,我尝试envelope.headerOut=header[0]但是得到上面的错误。我忘了输入上面的代码。但是我已经把envelope.headerOut=头放进去了在mycode中。不,它不是工作伙伴。仍然有returnRE

我正在使用此->>我认为您没有正确设置标题。我看不出您在哪里设置标题[0]。 也许你必须插入这行代码

envelope.headerOut = header;

I-face:类型不匹配:无法从元素转换到元素[]。能否尝试这行代码信封。headerOut=header;是的,我尝试
envelope.headerOut=header[0]但是得到上面的错误。我忘了输入上面的代码。但是我已经把
envelope.headerOut=头放进去了在mycode中。不,它不是工作伙伴。仍然有return
RESPONSE==HeaderInfo:,00000000-0000-0000-0000-000000000000
 private static final String    NAMESPACE   = "http://tempuri.org/";
 Element[] header = new Element[1];
 header[0]=buildAuthHeader();
 envelope.headerOut = header;
 Log.i("header", "" + envelope.headerOut.toString());

    envelope.dotNet = false;
    envelope.bodyOut = request;
    envelope.setOutputSoapObject(request);
    int Timeout = 15 * 1000;
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,1000*60*2);
    Log.i("bodyout", "" + envelope.bodyOut.toString());
    Log.i("REQUEST", "" + request.toString());

    try{
        androidHttpTransport.debug = true;
        androidHttpTransport.call(SOAP_ACTION, envelope);

        SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
        returnString = response.toString();
        Log.i("RESPONSE==", response.toString());
private Element buildAuthHeader() {
        String n_s = "ns";
            String web_user_test="john";
    int node_id=1234554;
    //String gid= UUID.randomUUID().toString();
    //String xmlns_soap1="http://schemas.xmlsoap.org/wsdl/soap/";
    //String Namespace="http://www.w3.org/2005/08/addressing";
    //String xmlns_soap="http://schemas.microsoft.com/2003/10/Serialization/";
    Element h = new Element().createElement(NAMESPACE, "ns");
    Element first = new Element().createElement(NAMESPACE, "web-user");
    first.addChild(Node.TEXT,web_user_test);
    h.addChild(Node.ELEMENT, first);

    Element second = new Element().createElement(NAMESPACE, "web-node-id");
    second.addChild(Node.TEXT, String.valueOf(node_id));
    h.addChild(Node.ELEMENT, second);

    Element third = new Element().createElement(NAMESPACE, "web-session-id");
    third.addChild(Node.TEXT, String.valueOf(UUID.randomUUID()));
    h.addChild(Node.ELEMENT, third);
        return h;
    }
            U= new User();
    U.setProperty(0, "horrorgoogle");
    U.setProperty(1,node_id);
    U.setProperty(2,UUID.randomUUID().toString());
    headerList.add(new HeaderProperty("web-user", U.getProperty(0).toString()));
    headerList.add(new HeaderProperty("web-node-id", U.getProperty(1).toString()));
    headerList.add(new HeaderProperty("web-session-id", U.getProperty(2).toString()));
   androidHttpTransport.call(SOAP_ACTION, envelope,headerList);
envelope.headerOut = header;