English 中文(简体)
Can t consume webservice from Java
原标题:

I created the webservice stubs using axis2-1.5 s wsdl2java.bat. This created a src folder with the following structure in it:

src/net/mycompany/www/services/SessionIntegrationStub.java

The package of the SessionIntegration.java file is: package net.mycompany.www.services;

Now, I am trying to use this stub in my java code. I placed my java file in the same services folder. I set the same package. Here is my entire class:

package net.mycompany.www.services;
import net.mycompany.www.services;

public class DynamicProxy 
{
  public static void main(String[] args) 
  {
    try 
    {
      SessionIntegrationStub stub = new SessionIntegrationStub();
      System.out.println(stub.getSessionIntegration("test"));
    }
    catch (Exception e) 
    {
      System.out.println(e);
    } 
  } 
}

Then I tried to compile this code with the following cmd:

javac DynamicProxy.java

However I keep getting this error message:

C:data
etmycompanywwwservices>javac DynamicProxy.java
DynamicProxy.java:9: cannot find symbol
symbol  : class SessionIntegrationStub
location: package net.mycompany.www.services
import net.mycompany.www.services.SessionIntegrationStub;
                                       ^
DynamicProxy.java:17: cannot find symbol
symbol  : class SessionIntegrationStub
location: class net.mycompany.www.services.DynamicProxy
                        SessionIntegrationStub stub = new SessionIntegrationStub();
                        ^
DynamicProxy.java:17: cannot find symbol
symbol  : class SessionIntegrationStub
location: class net.mycompany.www.services.DynamicProxy
                        SessionIntegrationStub stub = new SessionIntegrationStub();
                                                          ^
3 errors

Any idea what I am missing here?

Update 1:

I compiled the stubs (thanks to the answers below) and I got rid of the first error. I changed the import to this import net.americanapparel.www.services.*; however I still get an error for the SessionIntegrationStub: cannot find symbol. I also tried this import: net.americanapparel.www.services.SessionIntegrationStub, but that did not help either. Is there anything else I am missing?

问题回答

You have to compile your stub first or both together, since wsdl2java only creates a .java file, not the .class file. The compiler error clearly says it don t know the SessionIntegrationStub.

The other answer is right too: you have to

import net.mycompany.www.services.*;

not

import net.mycompany.www.services;

You don t seem to import it.

import net.mycompany.www.services.SessionIntegrationStub;

should do the trick.

and then:

shell$ javac my/package/*.java

which should enable javac to find or compile all the files it needs.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签