views:

37

answers:

2

Hello,

I had a .Net webService that returns a custom class, lets call it "MyClass", used like this example:

[WebMethod]
public MyClass sampleMethod()
{
    return new MyClass();
}

If works ok when invoked from a .Net application.

From a Java application using AXIS I am getting the error "MyClass is referenced but not defined".

How can I overcome this issue?

A: 

First, you have to create a Java proxy: This can be achieved by generating a client by pointing axis to the Web Service WSDL location.

Your Web Service might look like this: http(s)://server:port/path/service_def.asmx and add ?wsdl to the end of the wsdl definition (i.e. like this http(s)://server:port/path/service_def.asmx?wsdl).

From there, generate and client and use the proxy to talk to your .NET Web Service.


PS The possible cause for this is that your class is not defined in a namespace. Check your WSDL definition and see if there's an <xsd:element /> for your class and try adding an ns: to it and generate java proxy with Axis.

The Elite Gentleman
This error occurs creating the proxy...
Sergio
@Sergio Does creating the proxy VS work?
Richard
In VisualStudio everything works ok
Sergio
Your "MyClass" is declared as `WebMethod`. Can't you declare it as (like in java, since I don't know how to do it in .NET) `WebService` or `XmlRootElement`?
The Elite Gentleman
@The Elite Gentleman: MyClass is just a class that is returned by the Webmethod named "sampleMethod".
Sergio
A: 

Two things that spring to mind:

  1. You're missing a schema that defines MyClass
  2. A namespace issue surrounding the definition of MyClass

People will be able to help you further if you can post the WSDL and Schema(s)

Catchwa