Generated web service client doesn't match wdsl - java

After developing a web service on Eclipse, based on Axis1 and JBoss, I deploy it and test it with soapUI. It works perfectly.
Eclipse generates a wsdl file which I use in Eclipse's new web service client wizard to create an application client that consumes the web service. It generates the client code perfectly, but when I invoke some operations, I get the following error:
org.xml.sax.SAXException: Invalid element int ClassX - variableName.
How's that even possible? Everything was done using Eclipse's webservices tools for both generating the web service and the client. How can I check that my web service is getting generated correctly? What conditions should a complex object that is sended over a web service follow?

https://issues.apache.org/jira/browse/AXIS-2545
Is this along the same lines as your problem? I remember the wsdl axis tool sometimes mismatches element names, so instead of
elemField.setFieldName("**EventID**");
elemField.setXmlName(new javax.xml.namespace.QName("", "EventID"));
it comes out as
elemField.setFieldName("**eventID**");
elemField.setXmlName(new javax.xml.namespace.QName("", "EventID"));

Related

How to deploy webService and get access to wsdl?

I have got a webService without ui. It simple jax-ws app that will allow to manage users via soap requests. I tried to deploy it on websphere. It was deployed, But! my app doesn't appear in Service Providers and i can't get access to wsdl file via url that i pass in wsdlsoap:aderess location. It haven't got any servlets and other stuff. I create my app using template that deploy with success, it appear in Service Providers. I research all internet, but idk what go wrong.
P.S: Template project was eclipse project. I just add maven and has no idea why it wouldn't work.
The fact that your web service hasn't appeared in the Service Providers section means you've deployed it the wrong way.
Check whether you've selected the "Deploy web-services" option during deployment.
You probably got an issue in your trace.log file which possibly references to the ffdc, check it to investigate the problem.
You also haven't mentioned if you using servlet or EJB-based web services.

How to generate mock web service using WSDL in Java?

I have WSDL file and for local testing I need to generate mock web service.
Please do not recommend SoapUI.
Can anybody please help how to generate mock web service in Java using WSDL?
One option is to create a Web Services project using an IDE.
This will allow you to create a mock service and also implement your business logic.
As an example, using Eclipse:
Before starting, ensure that:
Eclipse has a server installed (Apache Tomcat)
Your WSDL file have a .wsdl extension (if not, rename as .wsdl)
Now, start Eclipse:
Create a new java "Dynamic Web Project"
Create a folder WebContent\wsdl and copy your WSDL file
Right-click on project > select new "Web Service"
Select:
Web Service type: "Top down Java bean Web Service"
Service definition: browser your WSDL file
Select "Start Service"
Select "Java Proxy / Start Client"
Select both option at the bottom of the form (publish/monitor)
Click next to complete process
At the end, your server should be started and WS deployed - check that your WSDL is available.
Now, you can:
call your WS using Eclipse Web Services Explorer see explorer
implement your WS mockup business logic see method implementation
or use a working java client to call your WS programmatically
Hope this help.
Try using Wiremock. However you will be needing to create and structure json/xml files according to your need. This will give you an better idea. Using WireMock with SOAP Web Services in Java

Generate WSDL from Java Web Service in Eclipse

I have a GAE web service with a few GETs and POSTs, I am required to have a WSDL of the web service.
I have found several pages and posts about generating a web service from WSDL but how would I generate a WSDL from an already created web service? I was told this is possible with only a few clicks in Eclipse.
Typically the WebService producer gives you the WSDL. Most web services you are able to get to the WSDL by postfixing ?WSDL to the URL. Keep in mind that, some web service providers disable this feature.
That is if you have a web service here
http://hostname:1234/webservice
you can use
http://hostname:1234/webservice?wdsl
to retrieve the WSDL

Error accessing Web Services from WSDL

After hours of working I have found a way to create a SOAP client that performs calls to web servers. I did two tests on public web servers and everything went okay. When I did a project with another server I got an error:
Web Service Client can not be created by JAXWS:wsimport utility.
Reason: 'Any' Property already defined. Use <jaxb:property> to
resolve this conflict
I am using Java EE 7 and Netbeans to create the web service client.
The problem maybe is that this web server requires a username and password to download the WSDL file.
How I can resolve this, and how can I enter a username and password to request the WSDL file?
EDIT:
The problem is not related to SSL, beacause I can access to WSDL from browser.

Call an axis2 web service from a java application

I have create one simple web service and I deploy it to the axis2 web application based on this tutorial
After creating my service, I am able to deploy it to the server and I can see the WSDL file by this url: localhost:8084/axis2/services/HelloAxisWorld?wsdl
Now, I want to call this service by an independent java application. I found some pieces of code that makes the invocation, but I am facing problems because I suppose that I don't include the proper libraries in my project.
Does anybody knows an example to call the web service by using axis2?
A simple Google for 'axis2 client tutorial' gives me this. It covers setting up your classpath properly, generating java from the WSDL via wsdl2java, and developing the client from this.

Categories