There are some interface methods that need to be called by the partner company due to work needs. Adjusted for an afternoon before the tune, write down, to make memo, no nonsense, direct code.
Import Javax.xml.namespace.qname;import Org.apache.axis.client.call;import Org.apache.axis.client.service;public Class Orderprocessclient {public static int getres (String user,string pwd,string orderno,string xmlstr) { try {//xml address (WSDL end) String endpoint = "HTTP://WC F.V-GROW.COM/ETRADE/ORDERPROCESS.SVC?WSDL "; Service service = new service (); Call Call Service.createcall (); Username Password Authentication call.setusername (user); Call.setpassword (PWD); Call.getmessagecontext (). Setusername (user); Call.getmessagecontext (). SetPassword (PWD); Call.settargetendpointaddress (endpoint); A: First line targetnamespace value B: Call Method name Call.setoperationname (new QName ("http://tempuri.org/", "Accept"); Call.setusesoapaction (TRUE); The Wsdl:input wsaw:action value Call.setsoapactionuri ("Http://tempuri.org/IOrderProcess/Accept") inside the called method; A: The first line targetnamespace value B: The parameter name must be the same as the parameter name of the. NET setting Call.addparameter (n EW QName ("http://tempuri.org/", "MsgId"), Org.apache.axis.encoding.XMLType.XSD_STRING, Javax.xml.rpc.ParameterMode.OUT)///interface parameter Call.addparameter (new QName ("http://tempuri.org/", "OrderNo"), org.apache.axis.encoding.xmltype.xsd_string,javax.xml.rpc.parametermode.in)///interface parameter Call.addparameter (n EW QName ("http://tempuri.org/", "Xmlstr"), Org.apache.axis.encoding.XMLType.XSD_STRING, Javax.xml.rpc.ParameterMode.IN)///parameters of the interface//set return type Call.setreturnt Ype (Org.apache.axis.encoding.XMLType.XSD_INT); Pass a parameter to the method, and call the method int i = (Integer) call.invoke (New Object[]{orderno, xmlstr}); return i; } catch (Exception e) {e.printstacktrace (); } return 2; public static void Main (string[] args) {String user = "username"; String pwd = "password"; String OrderNo = "123"; StringBuilder xmlstring = new StringBuilder (); Xmlstring.append ("<order orderid= ' 123456 '/>"); System.out.println (Getres (user,pwd,orderno,xmlstring.tostring ())); }}
Jar Package: http://download.csdn.net/detail/xlb744868186/8410873
Using Axis2 to invoke a WebService interface instance (Java) with a username and password