I'm trying to call webservice using ksoap2 I have Link http://localhost:8181/NetBeansProjects/WsDangNhap?WSDL.
<definitions targetNamespace="http://webservice.service/" name="WsDangNhap"><types><xsd:schema><xsd:import namespace="http://webservice.service/" schemaLocation="http://localhost:8181/NetBeansProjects/WsDangNhap?xsd=1"/></xsd:schema></types><message name="Tlu20DangNhapInsert"><part name="parameters" element="tns:Tlu20DangNhapInsert"/></message><message name="Tlu20DangNhapInsertResponse"><part name="parameters" element="tns:Tlu20DangNhapInsertResponse"/></message><message name="Tlu20DangNhapUpdate"><part name="parameters" element="tns:Tlu20DangNhapUpdate"/></message><message name="Tlu20DangNhapUpdateResponse"><part name="parameters" element="tns:Tlu20DangNhapUpdateResponse"/></message><message name="TestLogin"><part name="parameters" element="tns:TestLogin"/></message><message name="TestLoginResponse"><part name="parameters" element="tns:TestLoginResponse"/></message><message name="TLu20Delete"><part name="parameters" element="tns:TLu20Delete"/></message><message name="TLu20DeleteResponse"><part name="parameters" element="tns:TLu20DeleteResponse"/></message><message name="TLu20DangNhapFindUser"><part name="parameters" element="tns:TLu20DangNhapFindUser"/></message><message name="TLu20DangNhapFindUserResponse"><part name="parameters" element="tns:TLu20DangNhapFindUserResponse"/></message><message name="Tlu20dangNhapFindCommon"><part name="parameters" element="tns:Tlu20dangNhapFindCommon"/></message><message name="Tlu20dangNhapFindCommonResponse"><part name="parameters" element="tns:Tlu20dangNhapFindCommonResponse"/></message><portType name="WsDangNhap"><operation name="Tlu20DangNhapInsert"><input wsam:Action="http://webservice.service/WsDangNhap/Tlu20DangNhapInsertRequest" message="tns:Tlu20DangNhapInsert"/><output wsam:Action="http://webservice.service/WsDangNhap/Tlu20DangNhapInsertResponse" message="tns:Tlu20DangNhapInsertResponse"/></operation><operation name="Tlu20DangNhapUpdate"><input wsam:Action="http://webservice.service/WsDangNhap/Tlu20DangNhapUpdateRequest" message="tns:Tlu20DangNhapUpdate"/><output wsam:Action="http://webservice.service/WsDangNhap/Tlu20DangNhapUpdateResponse" message="tns:Tlu20DangNhapUpdateResponse"/></operation><operation name="TestLogin"><input wsam:Action="http://webservice.service/WsDangNhap/TestLoginRequest" message="tns:TestLogin"/><output wsam:Action="http://webservice.service/WsDangNhap/TestLoginResponse" message="tns:TestLoginResponse"/></operation><operation name="TLu20Delete"><input wsam:Action="http://webservice.service/WsDangNhap/TLu20DeleteRequest" message="tns:TLu20Delete"/><output wsam:Action="http://webservice.service/WsDangNhap/TLu20DeleteResponse" message="tns:TLu20DeleteResponse"/></operation><operation name="TLu20DangNhapFindUser"><input wsam:Action="http://webservice.service/WsDangNhap/TLu20DangNhapFindUserRequest" message="tns:TLu20DangNhapFindUser"/><output wsam:Action="http://webservice.service/WsDangNhap/TLu20DangNhapFindUserResponse" message="tns:TLu20DangNhapFindUserResponse"/></operation><operation name="Tlu20dangNhapFindCommon"><input wsam:Action="http://webservice.service/WsDangNhap/Tlu20dangNhapFindCommonRequest" message="tns:Tlu20dangNhapFindCommon"/><output wsam:Action="http://webservice.service/WsDangNhap/Tlu20dangNhapFindCommonResponse" message="tns:Tlu20dangNhapFindCommonResponse"/></operation></portType><binding name="WsDangNhapPortBinding" type="tns:WsDangNhap"><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/><operation name="Tlu20DangNhapInsert"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation><operation name="Tlu20DangNhapUpdate"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation><operation name="TestLogin"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation><operation name="TLu20Delete"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation><operation name="TLu20DangNhapFindUser"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation><operation name="Tlu20dangNhapFindCommon"><soap:operation soapAction=""/><input><soap:body use="literal"/></input><output><soap:body use="literal"/></output></operation></binding><service name="WsDangNhap"><port name="WsDangNhapPort" binding="tns:WsDangNhapPortBinding"><soap:address location="http://localhost:8181/NetBeansProjects/WsDangNhap"/></port></service></definitions>
Now I created a wsDangNhap on android studio, and Main Activity
public String TestLogin(String userName, String pass) throws XmlPullParserException, IOException {
SoapObject soapObject = new SoapObject("http://webservice.service/", "TestLogin");
soapObject.addProperty("username", userName);
soapObject.addProperty("pass", pass);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(soapObject);
HttpTransportSE transportSE = new HttpTransportSE("http://localhost:8181/NetBeansProjects/WsDangNhap?WSDL");
transportSE.call("TestLogin", envelope);
Object result = envelope.getResponse();
return String.valueOf(result.toString());
}
and main activity
private EditText userName;
private EditText passWords;
private Button button;
private TextView tv;
private Handler handler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
userName = (EditText) findViewById(R.id.userName);
passWords = (EditText) findViewById(R.id.passWord);
button = (Button) findViewById(R.id.button);
tv = (TextView) findViewById(R.id.textView);
button.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Thread t = new Thread();
t.start();
}
@Override
public void run() {
String uname = userName.getText().toString();
String pass = passWords.getText().toString();
try {
wsDangNhap dangNhap = new wsDangNhap();
final String result = dangNhap.TestLogin(uname,pass);
handler.post(new Runnable() {
@Override
public void run() {
userName.setText("debug: " + result);
}
});
} catch (Exception e) {
userName.setText("catch");
}
}
Now I can't see any resutl on userName field, and any log error.
Aucun commentaire:
Enregistrer un commentaire