ksoap2 connect https

1,387 views
Skip to first unread message

wangh...@163.com

unread,
Apr 2, 2011, 4:24:48 AM4/2/11
to ksoap2-android
I want to inter the https with the ksop2,and after connected
successfully I will find the message wsdl with explained, and then I
will received xml with be recoverd . After the app had run, when I
execute the way of "call", it said wrong .And then I try the
"post"and"socket" to connect, but I'm failed.

So I must to send messages to you for help, and please tell me some
information be related. And the in the annex is the used ksoap with be
packed by jar. The former edition is unused.

WSLD:http://webservices.sabre.com/wsdl/sabreXML1.0.00/usg/
SessionCreateRQ.wsdl
Request Sample:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:eb="http://www.ebxml.org/namespaces/messageHeader"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://
www.w3.org/1999/XMLSchema">
<SOAP-ENV:Header>
<eb:MessageHeader SOAP-ENV:mustUnderstand="1" eb:version="1.0">
<eb:ConversationId>2009-06-0249586768</eb:ConversationId>
<eb:From>
<eb:PartyId type="urn:x12.org:IO5:01">999999</eb:PartyId>
</eb:From>
<eb:To>
<eb:PartyId type="urn:x12.org:IO5:01">123123</eb:PartyId>
</eb:To>
<eb:CPAId>IPCC</eb:CPAId>
<eb:Service eb:type="OTA">SessionCreateRQ</eb:Service>
<eb:Action>SessionCreateRQ</eb:Action>
<eb:MessageData>
<eb:MessageId>1000</eb:MessageId>
<eb:Timestamp>2001-02-15T11:15:12Z</eb:Timestamp>
<eb:TimeToLive>2001-02-15T11:15:12Z</eb:TimeToLive>
</eb:MessageData>
</eb:MessageHeader>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/
secext" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/12/utility">
<wsse:UsernameToken>
<wsse:Username>1234</wsse:Username>
<wsse:Password>webcon1</wsse:Password>
<Organization>T6W8</Organization>
<Domain>DEFAULT</Domain>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<SessionCreateRQ>
<POS>
<Source PseudoCityCode="T6W8"/>
</POS>
</SessionCreateRQ>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


code:

private static final String HOST_STRING = "";
private static final int PORT = 443;
private static final String NAME_APACE = "https://
webservices.sabre.com/websvc";
private static final String METHOD_NAME = "SessionCreateRQ";
private static final String ACTION_NAME = "https://
webservices.sabre.com/websvc/SessionCreateRQ";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
HttpsTransportSE transportSE = new HttpsTransportSE(HOST_STRING,
PORT, "", 15000);

SoapObject object = new SoapObject(NAME_APACE, METHOD_NAME);
object.addProperty("Username", "1234");
object.addProperty("Password", "webcon1");

SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(object);
FakeX509TrustManager.allowAllSSL(); //this class may allow SSL
//this is error
transportSE.call(ACTION_NAME, envelope);
Object bodyIn = envelope.bodyIn;
Object bObject = envelope.bodyOut;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
Log.d("ksoap_test_error", "error");
}
}



static class FakeX509TrustManager implements X509TrustManager {
private static TrustManager[] trustManagers;
private final X509Certificate[] _AcceptedIssuers = new
X509Certificate[] {};

public void checkClientTrusted(X509Certificate[] chain, String
authType)
throws CertificateException {
}

public void checkServerTrusted(X509Certificate[] chain, String
authType)
throws CertificateException {
}

public boolean isClientTrusted(X509Certificate[] chain) {
return true;
}

public boolean isServerTrusted(X509Certificate[] chain) {
return true;
}

public X509Certificate[] getAcceptedIssuers() {
return _AcceptedIssuers;
}

public static void allowAllSSL() {
HttpsURLConnection.setDefaultHostnameVerifier(new
HostnameVerifier() {

public boolean verify(String hostname, SSLSession
session) {
return true;
}
});
SSLContext context = null;
if (trustManagers == null) {
trustManagers = new TrustManager[] { new
FakeX509TrustManager() };
}
try {
context = SSLContext.getInstance("TLS");
context.init(null, trustManagers, new SecureRandom());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
}
HttpsURLConnection.setDefaultSSLSocketFactory(context
.getSocketFactory());
}
}

kamal deen

unread,
Apr 3, 2011, 2:54:43 AM4/3/11
to ksoap2-...@googlegroups.com
Hai 
  i am not know what is the correct solution but i think use SoapPrimitive to recieve the response

Andrew Oppenlander

unread,
Apr 2, 2011, 5:37:51 AM4/2/11
to ksoap2-...@googlegroups.com

You are not constructing the soap envelope correctly. Currently your outgoing envelope looks something like this:

<env:header/>
<env:body>
<no:SessionCreateRQ xmlns:n0="NAMESPACE">
<n0:username>1234</n0:username>
<n0:password>webcon1</password>
</n0:SessionCreateRQ>
</env:body>

Reply all
Reply to author
Forward
0 new messages