Announcement Announcement Module
Collapse
No announcement yet.
This is my client program..Hessian. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • This is my client program..Hessian.

    Hi,

    This is my client program...

    URL url = new URL("http://localhost:8080/s2appv2/RemoteService");
    URLConnection uc = url.openConnection();
    FileInputStream fis = new FileInputStream(uploadFile);
    byte[] outbuf = new byte[ (int) uploadFile.length()];

    OutputStream os = uc.getOutputStream();
    HessianOutput out = new HessianOutput(os);
    out.startCall("uploadFile");

    while(-1 != (numBytes = fis.read(outbuf)) && !stop){
    out.writeBytes(outbuf);
    }
    out.completeCall();

    This is my Web.xml

    <servlet>
    <servlet-name>remote</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
    <load-on-startup>2</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>remote</servlet-name>
    <url-pattern>/RemoteService</url-pattern>
    </servlet-mapping>


    This is my remote-servlet.xml

    <beans>
    <bean id="remoteService" class="com.surgosystems.common.ServiceInterfaceImp l"/>

    <bean name="/RemoteService" class="org.springframework.remoting.caucho.Hessian ServiceExporter">
    <property name="service"><ref bean="remoteService"/></property>
    <property name="serviceInterface">
    <value>com.surgosystems.common.ServiceInterface</value>
    </property>
    </bean>
    </beans>


    This is my ServiceInferfaceImpl Class

    public void uploadFile()
    {
    System.out.println("SUCCESSFUL : Upload Stream Saved to .");
    }


    Am I doing correct...coz when I run the client program I don't see any messages in the server console. Your help is greatly appreciated.

  • #2
    Am I doing correct...coz when I run the client program I don't see any messages in the server console. Your help is greatly appreciated.
    If you're client program uses the right things (I don't know Hessian's client API that well), probably yes.

    But usage of the HessianServiceExporter is best done in combination with the HessianProxyFactoryBean. Using this (either setup programmatically or by including it in an app.ctx--mind you, all this at the lcient side), you don't have to do all this friggin' Hessian stuff yourself, it's all done for you.

    Have a look at the remoting docs, there's a pretty decent example there.

    Comment

    Working...
    X