web services - java.lang.IllegalArgumentException' faultactor: 'null' when using soap to call webservice from android device -
i create simple webservice connect android device. have used jax-ws follow guide: http://www.mkyong.com/webservices/jax-ws/jax-ws-spring-integration-example/
when run on client it's ok on device have fault. it's "soapfault - faultcode: 's:server' faultstring: 'java.lang.illegalargumentexception' faultactor: 'null' detail: org.kxml2.kdom.node@41aa21f0"
there wsdl file
<!-- published jax-ws ri @ http://jax-ws.dev.java.net. ri's version jax-ws ri 2.2.3-b01-. --> <!-- generated jax-ws ri @ http://jax-ws.dev.java.net. ri's version jax-ws ri 2.2.3-b01-. --> <definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.dic.med.com/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetnamespace="http://ws.dic.med.com/" name="webserviceservice"> <types/> <message name="getmed"> <part name="arg0" type="xsd:int"/> </message> <message name="getmedresponse"> <part name="return" type="xsd:string"/> </message> <porttype name="webserviceinterface"> <operation name="getmed"> <input wsam:action="http://ws.dic.med.com/webserviceinterface/getmedrequest" message="tns:getmed"/> <output wsam:action="http://ws.dic.med.com/webserviceinterface/getmedresponse" message="tns:getmedresponse"/> </operation> </porttype> <binding name="webserviceportbinding" type="tns:webserviceinterface"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> <operation name="getmed"> <soap:operation soapaction=""/> <input> <soap:body use="literal" namespace="http://ws.dic.med.com/"/> </input> <output> <soap:body use="literal" namespace="http://ws.dic.med.com/"/> </output> </operation> </binding> <service name="webserviceservice"> <port name="webserviceport" binding="tns:webserviceportbinding"> <soap:address location="http://192.168.248.1:8080/webservice1/smd"/> </port> </service> </definitions>
then code in android
package com.example.smdtestwebservice; import java.io.ioexception; import org.ksoap2.soapenvelope; import org.ksoap2.serialization.soapobject; import org.ksoap2.serialization.soapprimitive; import org.ksoap2.serialization.soapserializationenvelope; import org.ksoap2.transport.httptransportse; import org.xmlpull.v1.xmlpullparserexception; import android.annotation.suppresslint; import android.app.activity; import android.os.bundle; import android.os.strictmode; import android.view.menu; import android.widget.toast; public class mainactivity extends activity { private string method_name_1 = "getmed"; private string name_space = "http://ws.dic.med.com/"; private string soap_action_1 = name_space + method_name_1; private static final string url = "http://192.168.248.1:8080/webservice1/smd?wsdl"; @suppresslint("newapi") @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); if (android.os.build.version.sdk_int > 9) { strictmode.threadpolicy policy = new strictmode.threadpolicy.builder().permitall().build(); strictmode.setthreadpolicy(policy); } soapobject request = new soapobject(name_space, method_name_1); request.addproperty("arg0", 1); soapserializationenvelope envelope = new soapserializationenvelope(soapenvelope.ver11); envelope.dotnet = true; envelope.setoutputsoapobject(request); httptransportse androidhttptransport = new httptransportse(url); string = ""; try { androidhttptransport.call(soap_action_1, envelope); soapprimitive response = (soapprimitive) envelope.getresponse(); = response.tostring(); } catch (ioexception e) { e.printstacktrace(); } catch (xmlpullparserexception e) { e.printstacktrace(); } toast.maketext(this, a, toast.length_short).show(); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } }
anyone can me solve this?
i have updated code
webserviceinterface.java
package com.med.dic.ws; import javax.jws.webmethod; import javax.jws.webservice; import javax.jws.soap.soapbinding; import javax.jws.soap.soapbinding.style; @webservice @soapbinding(style = style.rpc) public interface webserviceinterface { @webmethod string getmed(int id); @webmethod string gethelloworld(string a); }
webservice.java
package com.med.dic.ws; import javax.jws.webmethod; import javax.jws.webservice; import com.med.dic.dao.medicinedao; @webservice(endpointinterface = "com.med.dic.ws.webserviceinterface") public class webservice implements webserviceinterface { private medicinedao medicinedao; @webmethod(exclude=true) public void setmedicinedao(medicinedao medicinedao) { this.medicinedao = medicinedao; } @override @webmethod(operationname="getmed") public string getmed(int id) { string medname = medicinedao.searchbyid(id).getmedname(); return medname; } @override @webmethod(operationname="gethelloworld") public string gethelloworld(string a){ return "jax-ws + spring! " + a; } }
Comments
Post a Comment