当前位置: 代码迷 >> Web Service >> [上海]100RMB请人教java的webservice解决办法
  详细解决方案

[上海]100RMB请人教java的webservice解决办法

热度:352   发布时间:2012-02-09 18:22:27.0
[上海]100RMB请人教java的webservice
有做过java项目,现在一个java项目需要用到webservice,这个系统是已经完成的,需要+个webservice的查询结果,不需要你完成,只要你教会我如何写,有个简单的用户名查询就可以了()。

java版太没有人气了,请斑竹留2天,需要着急学会用,项目马上开始啊。




------解决方案--------------------
定义接口,然后导出为WEBSERVICES
------解决方案--------------------
这个好像和语言没有什么关系吧!
------解决方案--------------------
用的什么服务器 tomcat or jboss
------解决方案--------------------
不会!帮顶了!
------解决方案--------------------
up
jf
------解决方案--------------------
第一步:装tomcat,第二步:装axis
写这样一个文件:MyMath.jws
public class MyMath
{
public int squared( int x ) {
return x * x;
}
}
把这个文件拷贝到“$CATALINA_HOME/webapps/axis/yourusername/ ",$CATALINA_HOME是tomcat的安装目录。yourusername是你的用户名。
然后你把MyMath.jws复制到另外一个地方,并命名为MyMath.java。假设复制到了WebService文件夹(随便写的)下。用javac命令编译MyMath.java。然后在WebService目录下运行
java -classpath \
$AXISCLASSPATH org.apache.axis.wsdl.WSDL2Java \
http://localhost:8080/axis/yourusername/MyMath.jws?wsdl
结果产生了一个目录。最低下有几个文件
MyMath.java: source for the Java interface for MyMath class.
MyMathService.java: source for the Java interface that includes the getMyMath method specification.
MyMathServiceLocator.java: source for the Java class MyMathServiceLocator.
MyMathSoapBindingStub.java: source for the Java class MyMathSoapBindingStub.
这些是用来写客户端的。在WebService目录下运行
javac -classpath \
$AXISCLASSPATH:$CLASSPATH \
localhost/axis/yourusername/MyMath_jws/*.java编译这些文件。
在WebService目录下create a file named 'MyMathClient.java ' that contains the code for the client. The client source code that you are to place in the 'MyMathClient.java ' file is given below.
// Required for Axis 1.1:
import localhost.axis.yourusername.MyMath_jws.MyMathServiceLocator;
import localhost.axis.yourusername.MyMath_jws.MyMathService;
import localhost.axis.yourusername.MyMath_jws.MyMath;
import org.apache.axis.client.*; // Axis 1.1
import org.apache.axis.encoding.XMLType; // Required as of Axis 1.2
import org.apache.axis.utils.Options; // Required as of Axis 1.2
import java.net.*; // Required for URL
import javax.xml.rpc.ParameterMode; // Required as of Axis 1.2
public class MyMathClient {
public static void main(String args[]) throws Exception {
MyMathService service = new MyMathServiceLocator(); // locate the service
Integer x = new Integer(args[1]); // Take the command line parameter
// and generate an Integer object.
Options options = new Options( args );
// Passing arguments. Required
// for getPort command.
String endpoint = "http://localhost: " + options.getPort() +
"/axis/yourusername/MyMath.jws "; // Tell the class where to
// look for service.
Call call = (Call) service.createCall(); // Designate that a call will
// be made.
call.setTargetEndpointAddress( new URL( endpoint ) ); // designate the
// target service
call.setOperationName( "squared " ); // the method name of the service
// define the parameters that the method requires.
call.addParameter( "op1 " , XMLType.XSD_INT, ParameterMode.IN);
// define the parameters that the method returns.
call.addParameter( "op2 " , XMLType.XSD_INT , ParameterMode.OUT );
// Set the return type of the call. (Required because of addParameter.)
call.setReturnType( XMLType.XSD_INT );
// Hold the result of the method call and make the call. (Invoke must
  相关解决方案