getting java.io.IOException: HTTP request failed, HTTP status: 404 in ksoap2 while passing xml data to soap1.2 android

a 夏天 提交于 2019-11-28 00:31:32

If still relevant..

First of all, you should change URL to http://myurl.com/Service.svc/Service.svc. It will solve 404 error.

Further you should change

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

to

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);

Further you should add wsa:To and wsa:Action headers like this:

        Element e = new Element();
        e.setName("To");
        e.setNamespace("http://www.w3.org/2005/08/addressing");
        e.addChild(Node.TEXT,"http://myurl.com/Service.svc/Service.svc");

        Element e1 = new Element();
        e1.setName("Action");
        e1.setNamespace("http://www.w3.org/2005/08/addressing");
        e1.addChild(Node.TEXT,"http://tempuri.org/ISilentManagerAPI/Service");

        envelope.headerOut = new Element[]{e,e1};

I hope it is helpful.

Edit: Try to change req to:

 PropertyInfo req = new PropertyInfo();
        req.name = "xmlstring";
        req.namespace=NAMESPACE;
        req.type = String.class;
        req.setValue("<hello><username>test@test.com</username><password>test</password></hello>");
        request.addProperty(req);

ie change req.name to xmlstring and set namespace.

Try the below

PropertyInfo req = new PropertyInfo();
req.name="silent";
req.type=String.class;
req.setValue("<silent>"
+"<action>"+logon+"</action>"
+"<gameid>"+mygameid+"</gameid>"
+"<gpassword>"+mypwd+"</gpassword>"
+"<data>"
+"<username>"+test@test.com+"</username>"
+"<password>"+test+"</password>"
+"</data>"
+"</silent>");
request.addProperty(req);   
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!