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

后端 未结 2 1691
有刺的猬
有刺的猬 2020-12-06 15:10

i have to pass


test@test.com
test

        
相关标签:
2条回答
  • 2020-12-06 15:35

    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.

    0 讨论(0)
  • 2020-12-06 15:58

    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);   
    
    0 讨论(0)
提交回复
热议问题