JAVA调用WSDL问题

鸿尚法师 发布于 2014/01/06 18:43
阅读 1K+
收藏 0

源码

public static void main(String[] args) {

 try {
              String endpoint = "http://218.2.104.188:5050/frdif/n_frdif.asmx";


              Service service = new Service();
              Call call = (Call) service.createCall();
              call.setTargetEndpointAddress(endpoint);
              call.setOperationName("processdata");
              
              call.addParameter("userid", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);//接口的参数
              call.addParameter("password", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);//接口的参数
              call.addParameter("cmdid", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);//接口的参数
              call.addParameter("inputpara", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);//接口的参数
              
              call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型  


              String result = (String)call.invoke(new Object[]{"test","00B54E5ADD61AC9C","1013","3,00001"});


              System.out.println("result is "+result);
       }catch (Exception e) {
              System.err.println(e.toString());
       }

}

错误:

Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/internet/MimeMultipart
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.axis.utils.ClassUtils$2.run(ClassUtils.java:177)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.utils.ClassUtils.loadClass(ClassUtils.java:160)
at org.apache.axis.utils.ClassUtils.forName(ClassUtils.java:100)
at org.apache.axis.Message.isAttachmentSupportEnabled(Message.java:277)
at org.apache.axis.Message.setup(Message.java:346)
at org.apache.axis.Message.<init>(Message.java:246)
at org.apache.axis.client.Call.invoke(Call.java:2425)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at dg.spf.wsdl.MemberWsdl.main(MemberWsdl.java:34)


加载中
0
蘑菇喵
蘑菇喵
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class TestWebservice {
	public static void main(String[] args) throws Exception {
		try {
			String endpoint = "http://218.2.104.188:5050/frdif/n_frdif.asmx";
			Service service = new Service();
			Call call = (Call) service.createCall();
			call.setTargetEndpointAddress(new java.net.URL(endpoint));
			call.setSOAPActionURI("http://tempurl.org/processdata");
			call.setOperationName("processdata");
			String res = (String) call.invoke(new Object[] {"test","00B54E5ADD61AC9C","1013","3,00001"});
			System.out.println(res);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

返回值是-1 用你的参数简单调用了一下 上面是jar包 



返回顶部
顶部