【问题标题】:Android wshttpbinding supportAndroid wshttpbinding 支持
【发布时间】:2014-08-05 10:08:26
【问题描述】:

我想连接到 Soap 1.2 网络服务,但据我了解,android 不支持 wshttpbindings。所以我尝试了应该能够发送正确的肥皂动作的 ksoap2 库。

        SoapObject request = new SoapObject(NAMESPACE, SOAP_METHOD);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
        envelope.implicitTypes = true;
        envelope.dotNet = true;
        envelope.headerOut = SoapUtils.buildHeader(SSL_URL, SOAP_ACTION);

我什至尝试编写标题,但我只是不确定 wshttpbinding 真正需要哪些标签。 有谁知道如何在android下使用wshttpbinding?我已经看了其他问题,但没有任何效果。请帮忙。

【问题讨论】:

    标签: android wcf soap wshttpbinding


    【解决方案1】:

    最好尝试使用 basicHttpBinding。 wsHttpBinding 使用 Android 不支持的一些高级消息安全性(取决于您的设置)。传输安全 (ssl) 会更容易。

    【讨论】:

    • 我知道basicHttpBinding会更容易,但我没有编写wsdl服务,所以我没有选择。但是在android中模拟一个wshttpsbinding是不可能的。 PS:该服务具有自签名证书和凭据,这使得它更加复杂。
    • 服务器使用的确切 wshttpbinding 配置是什么?
    • 这是 100k 的问题。我不知道,因为我的老板提供了服务,而我没有访问权限。但是,如果无法调用服务,他必须更改服务设置,或者我编写第二个访问 wsdl 服务的 dotNet Rest 服务。我没有看到另一种方式。你呢?
    • 你有服务的WSDL吗?它有 ws-policy 标签,可以说明什么是服务器绑定
    • 是的,我有 wsdl,但它不包含 ws-policy 标签。我有 wsp:Policy 标签,其中包括 sp:TransportBindings。是指这些标签吗?
    【解决方案2】:

    我已连接到 wsdl 服务。线索是该服务需要一个返回 SecurityContextToken 的主请求。附加请求需要此令牌。第一个肥皂信封是这样的:

    如果我将此肥皂信封发送到服务,它会返回可用于其他请求的 SecurityToken。 但我不确定 SecurityTokenRequest 真正需要哪些标签,因为在这个请求中,有一些 uid 和标签值每次都会改变,我不知道它们是如何构造的。例如 MessageId、UserToken id、BinarySecret Tag、...

    有人知道哪些标签是关键的,哪些不是吗?

    我使用了一个 HttpsUrlConnection 和一个 OutputStream:

            URL url = new URL(SSL_URL);
            HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
            urlConnection.setDoOutput(true);
            urlConnection.setSSLSocketFactory(context.getSocketFactory());
            urlConnection.setHostnameVerifier(hostnameVerifier);
            urlConnection.setRequestProperty("Content-Type", "application/soap+xml; charset=utf-8");
            urlConnection.connect();
            OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());
            if (out != null)
            {
               out.write(getReqData());
               out.flush();
               out.close();
            }
            int res = urlConnection.getResponseCode();
            String message = urlConnection.getResponseMessage();
            InputStream in = urlConnection.getInputStream();
            String msg = convertStreamToString(in);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多