PDA

View Full Version : This is my client program..Hessian.



kotesh
Oct 6th, 2004, 03:42 AM
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.DispatcherServlet</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.ServiceInterfaceImpl"/>

<bean name="/RemoteService" class="org.springframework.remoting.caucho.HessianService Exporter">
<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.

Alef Arendsen
Oct 6th, 2004, 03:44 PM
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.