本文介绍了如何调用WCF HTTPS肥皂从WsHttpBinding的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法从Android调用WCF HTTPS与KSOAP WsHttpBinding的?
Is there any way to call HTTPS wcf ksoap from Android with WSHttpBinding?
通过HTTP和basicHttpBinding的它工作正常,但我不能让它使用HTTPS和WsHttpBinding的工作。
With http and basichttpbinding it is working fine but I can't get it to work with HTTPS and WSHttpBinding.
推荐答案
对于WsHttpBinding的支持
KSOAP将支持WsHttpBinding的。使用Version12标签。
KSoap will support WSHttpBinding. Use Version12 tag.
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
soapEnvelope.implicitTypes = true;
soapEnvelope.dotNet = true;
soapEnvelope.headerOut = SoapUtils.buildHeader(url, soapAction);
所需的标题添加到信封
Add the required Headers to the Envelope
private static final String HTTP_ADDRESSING_ANONYMOUS = "http://www.w3.org/2005/08/addressing/anonymous";
private static final String HTTP_ADDRESSING = "http://www.w3.org/2005/08/addressing";
private static final String ACTION = "Action";
private static final String TO = "To";
private static final String ADDRESS = "Address";
private static final String REPLY_TO = "ReplyTo";
private static final String MUST_UNDERSTAND = "mustUnderstand";
private static Element[] buildHeader(String url, String soapAction) {
List<Element> headers = new ArrayList<Element>();
Element elementAction = new Element().createElement(HTTP_ADDRESSING, ACTION);
elementAction.addChild(Node.TEXT, soapAction);
elementAction.setAttribute(HTTP_ADDRESSING, MUST_UNDERSTAND, "1");
headers.add(elementAction);
Element elementTo = new Element().createElement(HTTP_ADDRESSING, TO);
elementTo.addChild(Node.TEXT, url);
elementTo.setAttribute(HTTP_ADDRESSING, MUST_UNDERSTAND, "1");
headers.add(elementTo);
Element elementReplyto = new Element().createElement(HTTP_ADDRESSING, REPLY_TO);
Element address = new Element().createElement(HTTP_ADDRESSING, ADDRESS);
elementReplyto.addChild(Node.ELEMENT, address);
address.addChild(Node.TEXT, HTTP_ADDRESSING_ANONYMOUS);
elementReplyto.setAttribute(HTTP_ADDRESSING, MUST_UNDERSTAND, "1");
headers.add(elementReplyto);
int size = headers.size();
Element[] array = new Element[size];
for (int i = 0; i < size; i++) {
array[i] = headers.get(i);
}
return array;
}
支持HTTPS
创建一个假证书并允许使用SSL。
Create a Fake Certificate and allow SSL.
这篇关于如何调用WCF HTTPS肥皂从WsHttpBinding的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!