[Mono-list] Consuming WebService

Nicky.Hochmuth nicky.hochmuth at fhnw.ch
Fri Sep 17 08:17:27 EDT 2010


Hello Mono-Community

I developed a Silverlight application (with VS for Windows)that presents
some data received from a WebService. I also host and develop the concerning
WebService.

The WebService is written in Java (javax.jws.*) and is running on a Sun
GlassFish Enterprise Server v2.1.1.
and is working fine for Java, .Net and Silverligth clients.

You will find the WebService here: 
http://147.86.9.121:48148/WRCServer/ContaminantService?WSDL
http://147.86.9.121:48148/WRCServer/ContaminantService?WSDL 

And the required clientaccesspolicy.xml here: 
http://147.86.9.121:48148/clientaccesspolicy.xml
http://147.86.9.121:48148/clientaccesspolicy.xml 

The deployment descriptor (web.xml) is very basic and contains the
following:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID"
version="2.5">
  <display-name>WRC</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

</web-app>


The problem is that the WebService communication with a Mono-Client does not
work and also the Silverligth-App. does not communicate with the service in
the Moonligth plugIn.

I created a mono-client with:

wsdl2 http://147.86.9.121:48148/WRCServer/ContaminantService?WSDL

compiled it with:

gmcs /target:library ContaminantService.cs -r:System.Web.Services


I wrote the following test application: wrctest.cs


using System;
 
class WRCTest
{
	public static void Main (string [] args)
	{
		ContaminantService Service1 = new ContaminantService();
		
		Service1.aliveCompleted += new aliveCompletedEventHandler(alive);
		Service1.getRangeCompleted += new getRangeCompletedEventHandler(range);

		Console.WriteLine("Service URL: "+Service1.Url);		

		//Service1.aliveAsync();
		
		//create a user state / not really necessary
		DateTime userState = DateTime.Now;
		Console.WriteLine("State: "+userState);
		
		//call the service for H20 with userState
		Service1.getRangeAsync("H2O",userState);
		
		//wait for replay
		Console.ReadLine();

	}

	private static void alive(object sender, aliveCompletedEventArgs args)
	{
		Console.Write("Service alive response: ");
		Console.WriteLine(args.Result);
	}

	private static void range(object sender, getRangeCompletedEventArgs args)
	{
		Console.Write("Service range response: ");
		Console.WriteLine(args.Result.contaminantName);
	}
}


and compiled it with: 

gmcs /r:ContaminantService.dll wrctest.cs

the application (running with "mono wrctest.exe" on a xubuntu OS) does not
behave like expected.

I call the the WebMethod (getRange(String)) only once but the
getRangeCompleted event is fired twice but without any result. 
The output is:


Service URL: http://147.86.9.121:48148/WRCServer/ContaminantService
State: 9/17/2010 2:06:42 PM
Service range response: Service range response:


The expected result would be a complex type providing additional
informations for the input (H2O).
Also if i call the Alive() WebMethod that should return the basic bool
(true) result nothing is happen.

If i copy and run the wrctest.exe to a WinXp OS i receive at least a
NullReferenceException

Service URL: http://147.86.9.121:48148/WRCServer/ContaminantService
State: 17.09.2010 11:53:14
Service range response:
Unbehandelte Ausnahme: System.NullReferenceException: Der Objektverweis
wurde ni
cht auf eine Objektinstanz festgelegt.
   bei WRCTest.range(Object sender, getRangeCompletedEventArgs args)
   bei ContaminantService.OngetRangeCompleted(Object arg)
   bei System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object
state)
   bei System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
   bei
System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback
tpWaitCallBack)
   bei System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object
state)


Has anybody an idea what is wrong? Do I build the mono-client in a wrong way
or do I have to configure the WebService in an other way?

Thank you all in advanced for your kind assistance.

Best regards
Nicky Hochmuth


-- 
View this message in context: http://mono.1490590.n4.nabble.com/Consuming-WebService-tp2543783p2543783.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list