I try to create web service to Axis2.
I am use eclipse and the "Axis2 Service Archiver" to create aar file from java class.
My problem is that I have function that return custom class like:
public TestClass TestFunc(){
return new TestClass();
}
My question is how my client know what is TestClass? , the TestClass don't show in the wsdl file.
Thanks For the help
If you can see the operation TestFunc() appears in the WSDL - you should be able to see type corresponding to the TestClass in your WSDL. If you cant see, how does the WSDL show the return type of the TestFunc() in the WSDL..?
Thanks..
Related
I'd really like to use Errai UI(3.2.4) in my GWT (2.8) application. I already have one setup with an EntryPoint implementation and an onModuleLoad. I have restGWT setup and interacting with my server (which uses Jersey).
All of the documentation I find assumes that you are building a full-on Errai project, starting from scratch using the forge addon thing. I'm not. I just want to use the templating stuff and data-binding. I'm working with a barebones setup and I can't even make a label show in my app.
I have this GWT entry point:
public class App implements EntryPoint
{
#Inject
private ApplicationContainer applicationContainer;
public void onModuleLoad()
{
RootPanel.get("root").add(applicationContainer);
}
}
And the ApplicationContainer:
#Templated
public class ApplicationContainer extends Composite
{
#DataField
private Element applicationContainer = DOM.createDiv();
#PostConstruct
public void init()
{
GWT.log("Initializing");
}
}
And it's accompanying template:
<div id="applicationContainer" data-field="applicationContainer">
Application Container
</div>
I should see "Application Container" in the browser, but I get this error in the browser console:
ComplexPanel.java:96 Uncaught TypeError: Cannot read property 'removeFromParent_0_g$' of undefined
The widget and the template are named the same and in the same package. My widget is created just like the documentation shows: http://erraiframework.org/getting-started/index.html#ErraiUIPage
Can someone tell me what I'm missing here? Examples for this are very minimal, and they all assume a complete Errai project. Do I still need an #EntryPoint? Do I need #PostConstruct? Is Errai even designed to work like this?
Thanks for any help.
Yes, the #EntryPoint annotation is important and I'm not sure you'll be able to mix up part of this framework with some other approach. It doesn't mean you need to use all the modules, but you should rather follow the Errai's guidelines if about the part you use.
Please see example entry point here:
https://github.com/errai/errai/blob/3.2.4.Final/errai-demos/errai-jpa-demo-todo-list/src/main/java/org/jboss/errai/demo/todo/client/local/ClientEntryPoint.java
You'll find also more examples from the path .../3.2.4.Final/errai-demos/
Above is about Errai 3.x.
Please also note that Errai 4.x brings some changes if it is just about the Errai UI. It's nicely described here:
http://errai-blog.blogspot.com/2016/04/errai-400beta1-released.html
Now your #Templated bean do not need to extend Composite. The root element of the template is accessible as a #DataField etc.
Hope you'll find it helpful. Good luck!
The answer to your questions is here: https://github.com/errai/errai-tutorial
You basically need to migrate your app to use Maven so you get the dependencies right first, then use the POM in this project and snap it in your project.
Then you can include a Bootstrap file to add a #EntryPoint class however this is not necessary you can just add a Page in the client path e.g.:
com.mycompany.app.client
-->MyPage.html
-->MyPage.java
Where the java file here contains the default page, i.e.
#Dependent
#Templated
#Page(role = DefaultPage.class)
public class MyPage extends Composite{}
I have util class with one method:
public static void setStyleForWidgetLayout(HTMLPanel panel, int rowQuantity) {
Which for each Widget in HTMLPannel assign widgth depends on number of widgets and rows.
It is very simple switch.
I want to test this method but when i create test with normal JUnit test case i recieve error on creating HTMLPanel.
Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code! It cannot be called, for example, from server code. If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
Next I tried to extend GWTTestCase but it requires to implement getModuleName() but i dont have any particular module because the class I test is just util class
Ok, I thought, lets mock it. I used mockito, but the errror occured, same as from previous code section.
Than I found class GwtTestWithMockito and tried to run this and again I recieved error.
com.googlecode.gwt.test.exceptions.GwtTestConfigurationException: No declared module. Did you forget to add your own META-INF/gwt-test-utils.properties file with a 'gwt-module' property in the test classpath?
I added #GWTModule and this META-INF/gwt-test-util.properties. And experimented with different configurations. I tried existing module names and not existing ones but still i recieve error above.
Thanks in advance
I'm afraid you have to use GWTTestCase. Your module name is the name of your module XML file.
Sometimes you have to add your Panel to the root panel, I generally do this just to be on the safe side.
I created a Web Service Consumer.
I want to call a method that is named setCredentials so I can pass my authentication information to the service.
I have two entities that import the web service consumer, an agent and a java library, meant to be called from LotusScript.
The strange thing is that on my agent everything works fine. Library compiles OK, but when it is executed from LotusScript and reaches that line
stub.setCredentials("xxxx","ttttt");
Java throws a java.lang.nosuchmethod error. What can I be doing wrong?
Thank you so much in advance for your help.
Update:
Maybe I didn't explain fully. The action occurs fully inside java. This is sort of a test. On LotusScript I am just calling the constructor with the sequence GetClass/CreateObject. The code is inside the constructor (For test sake). And it looks precisely the same, both on my test agent and on java library. Answering your question, Jason, no , setCredentials is part of a certain lotus.domino.types.PortTypeBase Interface. When I consume the .wsdl to create a web service consumer, I can see from the generated .java files that my interface extends portTypeBase and Remote
It is not possible to call a Java Web Service consumer from LotusScript (LS2J). This is detailed in SPR SODY7UDKE8 / APAR LO42772. This also applies to calling a Java agent which in turn calls a Java consumer.
You will need to create a LotusScript consumer to access the web service in LotusScript. However there are known limitations in LotusScript which can prevent some web services from being consumed.
40 character variable/method limit
Extremely large SOAP messages can cause performance/crash issues.
Reserved keywords mismatch in LS/WSDL/SOAP.
That said I created the following sample Provider.
Class wsClass
Function hello ( helloText As String) As String
hello = "Hello " + helloText
End Function
End Class
In the NSF it was stored I set it to only allow authenticated users.
I then created a LS consumer and Java Consumer libraries from the generated WSDL.
After that I created the following sample code.
LotusScript
Use "LsWebServiceConsumer"
Sub Initialize
Dim stub As New Wsclass
Dim answer As String
Call stub.Setcredentials("testuser", "password")
answer = stub.Hello("world")
MsgBox answer
End Sub
JAVA (added consumer library to agent)
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
WsClass stub = new WsClassServiceLocator().getDomino();
stub.setCredentials("testuser", "password");
System.out.println(stub.HELLO("world"));
} catch(Exception e) {
e.printStackTrace();
}
}
}
Both of these worked as expected with their own respective consumer.
I am using Struts 2 to create a web application. I am using StrutsTestCase for Junit test case to test the Action class. I have imported struts2-junit-plugin-2.3.4.jar as I am using struts2-core-2.3.4.jar. Inside the testcase method, when i tried to set the request parameters, request variable is not available for use. it is showing compilation error. I am getting 'request cannot be resolve' error. In my test class i am extending StrutsTestCase which has request as protected parameter. But it is not available inside extended method.
My test action looks like this:
import org.apache.struts2.StrutsTestCase;
public class WallPlanningActionTest extends StrutsTestCase {
public void testList() {
request.setParameter("salesOrg",1);
}
You can only get compilation errors if StrutsTestCase which your class is extended is not org.apache.struts2.StrutsTestCase. You could optimize the imports or just use FQCN.
public class WallPlanningActionTest extends org.apache.struts2.StrutsTestCase {
For future readers:
I had the same problem - the protected request field was not accessible. The problem was that i hadn't add the spring libraries. StrutsTestCase uses spring-core-x.y.z and spring-test-x.y.z. It is depended on them an i couldn't find a way to use the unit tests without them.
Other dependencies could be found by opening the struts-junit-plugin jar (as archive). Open the META-INF folder and in there you will find DEPENDENCIES file with a list of all dependencies.
Hope this helps someone.
I am beginner in java web-services.
I created a simple web service and when trying to publish it as below
Endpoint.publish("http://localhost:8080/HelloWeb", new HelloWeb());
Getting error as below
Exception in thread "main" com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class com.ravi.jaxws.SayGreeting is not found. Have you run APT to generate them?
at com.sun.xml.internal.ws.model.RuntimeModeler.getClass(RuntimeModeler.java:256)
at com.sun.xml.internal.ws.model.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:567)
at com.sun.xml.internal.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:514)
at com.sun.xml.internal.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:341)
at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:227)
at com.sun.xml.internal.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:308)
at com.sun.xml.internal.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:174)
at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:420)
at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:439)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:208)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:138)
at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:90)
at javax.xml.ws.Endpoint.publish(Endpoint.java:170)
at com.ravi.Server.main(Server.java:9)
Any Idea whats going wrong here.
My webservice class is very simple and here is code:
#WebService
#SOAPBinding(style = Style.DOCUMENT, use=Use.LITERAL)
public class HelloWeb {
#WebMethod
public String sayHello(String name){
return "Hello "+name;
}
}
first invoke the wsgen utility. This utility generates the various artifacts , i.e. java types needed by the method Endpoint.publish to generate the service's WSDL.Here is the example
In the working directory run
wsgen -keep -cp package.HelloWeb