最近做完一个项目用的是JSE1.6,需要提供接口供主控计算机控制访问(用的是webservice),请问我如何在java工程里编程,才能让客户端访问我这里的应用程序,请说明的详细一些,本人对J2SE和web开发都不太懂,谢谢

解决方案 »

  1.   

    http://topic.csdn.net/u/20080425/00/33A47C75-07D4-49E0-9628-BE23554AB142.html
      

  2.   

    webservice应该是属于j2ee的内容吧,需要web容易的支持。
      

  3.   

    需要按照webservice方式写java程序。并需要发布到你们的系统(应该是个web应用)中。
    这样你只要告诉客户的方法以及参数,你的客户就可以在他们自己的程序中使用你提供的功能。至于如何用webservice方式写java程序并发布,需要参考一些资料。
      

  4.   

    利用cxf开发WebService(转载) http://www.cnblogs.com/orchidsure/archive/2009/05/12/1455089.html
      

  5.   

    package hello;
    import javax.jws.WebService;
    import javax.xml.ws.Endpoint;@WebServicepublic class CircleFunctions {
       public double getArea(double r) {
       System.out.println("Hello Web Service");
           return java.lang.Math.PI * (r * r);
        }   public double getCircumference(double r) {
            return 2 * java.lang.Math.PI * r;
        }
          public static void main(String[] args) {         Endpoint.publish(
                "http://localhost:9800/WebServiceExample/circlefunctions",
                new CircleFunctions());   }
    }client side
    package hello.client;public class Client {

    public static void main(String[] args) {
            try {
             hello.client.jaxws.CircleFunctionsService service =
                    new hello.client.jaxws.CircleFunctionsService();
             hello.client.jaxws.CircleFunctions port = service.getCircleFunctionsPort();            double arg0 = 3.0;            double result = port.getArea(arg0);
                System.out.println("Result = "+result);
            } catch (Exception ex) {
             ex.printStackTrace();
            }    }
    }xml build file:
    <project name="webservice.example" default="compilesrc" basedir=".">
    <property file="build.properties" />
    <property name="sourcedir" value="${basedir}/src" />
    <property name="testscrdir" value="${basedir}/dev/test" />
    <property name="targetdir" value="${basedir}/target" />
    <property name="buildclass" value="${targetdir}" /> <target name="clean">
    <delete dir="${buildclass}" />
    <delete dir="${targetdir}" />
    </target> <target name="compilesrc" depends="clean" >
    <echo level="info" message="compile source code classes" />
    <mkdir dir="${buildclass}" />
    <javac debug="true" srcdir="${sourcedir}" destdir="${buildclass}" classpathref="libraries" />
    </target> <target name="copy-resources">
    <copy todir="${targetdir}">
    <fileset dir="${sourcedir}">
    <exclude name="**/*.java" />
    </fileset>
    </copy>
    </target> <path id="jaxws.classpath">
    <fileset dir="${jaxws.home}/jaxws_lib">
    <include name="**/*.jar" />
    </fileset>
    </path> <path id="libraries">
    <pathelement path="${buildclass}" />
    <path refid="jaxws.classpath"/>
    </path> <!-- Define the Jax WS ant tasks -->
    <taskdef name="Apt" classname="com.sun.tools.ws.ant.Apt">
    <classpath refid="libraries"/>
    </taskdef> <!-- Define the Jax WS ant tasks -->
    <taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
    <classpath refid="libraries"/>
    </taskdef>

    <taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen">
    <classpath refid="libraries"/>
    </taskdef> <target name="genwsartifacts">
    <wsgen sei="hello.CircleFunctions"
    destdir="target" resourcedestdir="config" sourcedestdir="src" 
    keep="true" verbose="true" genwsdl="true" fork="true">
    <classpath refid="libraries" />
    </wsgen>

    <wsimport debug="true" verbose="true" keep="true" 
    destdir="target" sourcedestdir="src" 
    package="hello.client.jaxws" 
    wsdl="config/CircleFunctionsService.wsdl">
    </wsimport>
    </target>

    <target name="postprocess" description="Post process the wsdl and the schema files" depends="genwsartifacts">
    <!-- Replace the URL token -->
    <replace file="config/CircleFunctionsService.wsdl" token="REPLACE_WITH_ACTUAL_URL" value="${soap.address}"/>
    <replace file="config/CircleFunctionsService_schema1.xsd" token="minOccurs=&quot;0&quot;"/>
    </target>
    </project>
      

  6.   

    另外你可以使用spring的standalone 的 web service component 
    本质上来说,任何在J2EE中应用的组件,都可以被移植到J2SE上