I'm using Apache axis2 and more specifically, the wsdl2java tool to generate the stubs for a web service and create a client, given the wsdl file.
When I try to generate stub classes for a paypal web service (its wsdl file is here) axis won't generate stubs for both the bindings included to the wsdl but just for the second one (PayPalAPIAASoapBinding)
Has anybody worked on this wsdl with apache's wsdl2java tool before?
I've been struggling with this, too.
Short answer:
Append -pn PayPalAPI to your Axis2 command.
Long answer:
Take a look at following lines of the PayPal WSDL:
<wsdl:service name="PayPalAPIInterfaceService">
<wsdl:port name="PayPalAPI" binding="ns:PayPalAPISoapBinding">
<wsdlsoap:address location="https://api.sandbox.paypal.com/2.0/"/>
</wsdl:port>
<wsdl:port name="PayPalAPIAA" binding="ns:PayPalAPIAASoapBinding">
<wsdlsoap:address location="https://api-aa.sandbox.paypal.com/2.0/"/>
</wsdl:port>
</wsdl:service>
Obviously, the WSDL specifies 1 service with 2 ports. Our problem is that Axis2 only creates the stub for the second port, "PayPalAPIAA" but not for the port "PayPalAPI".
Now, take a look at the Axis 2 command line option reference (http://ws.apache.org/axis2/tools/1_2/CodegenToolReference.html#cmdref), specifically, at the description of the option -pn:
"Specifies the port name to be code generated. If the port name is not specified, then the first port (of the selected service) will be picked."
Thus, specifying -pn PayPalAPI does the trick.
apon,
I used Eclipse and created a new Web Service Client project and pointed to the URL you mentioned. I think i was able to create both the stubs. Can you please try creating stubs from Eclipse IDE once?
Related
From a colleague I have received a WSDL file that describes the web service he is offering, and which I am supposed to call from my code. I would now like to do two things:
1) Implement the client
2) Have a stub server that I can use for testing, until I have access to the real server.
What I tried is the following:
wsimport -clientjar foo.jar foo.wsdl
This gives me a jar file that contains the Datatype that will contain the data to be posted to the web service, and also an ObjectFactory. I guess I will have to use it as follows:
TestDataType testDataType = new TestDataType();
testDataType.setFoo("foo");
testDataType.setBar("bar");
ObjectFactory objectFactory = new ObjectFactory();
JAXBElement<TestDatatype> request = objectFactory.createTestRequest(testDatatype);
Now how do I send this request?
Also a class TestDemoService annotated with #WebServiceClient has been generated. How do I run this class?
Any advice is highly appreciated.
You've created the client. To use this client you need to set the endpoint(if not already set) and call the service using the generated api.
This site should be a good reference.
Using wsimport
I am in .NET environment and I am supposed to reference and consume a java WebService with a WSDL.
I am not a wsdl master and neither have I done extensive work in WCF but normally WCF has two kind of binding which are BasicHTTP and WSHTTP but it sounds like I am not able to find any details on this looking at the WSDL. instead I do see something like following:
<wsdl:port name="SFAPI12" binding="tns:SFAPISoap12Binding">
<wsdlsoap12:address location="https://api.successfactors.eu:443/sfapi/v1/soap12" />
</wsdl:port>
followed by
<wsdl:binding name="SFAPISoapBinding" type="tns:SFAPI"><wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
I have no idea how to consume it in my C# application. Any ideas?
Right click the ServiceReference folder in your C# project, click on 'Add new service reference'. Give the java wsdl and enter an alias name for this service. Once this is done, then you can start using this alias for making client calls to the service.
You can use tool svcutil.exe.
Run from command line:
svcutil *.wsdl
It generates ".cs" and ".config" files.
svcutil.exe usually placed in directory:
c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\
or similar.
Trying to integrate with axis camera to manage events and actions as described here http://www.axis.com/files/manuals/vapix_event_action_51386_en_1307.pdf
While generating service from wsdl provided in docs have stub instead of service. After quick review of wsdl found out that no service definition provided. How to deal with it?
I've resolved it by adding service definition to wsdl file like this:
<wsdl:service name="EventClient">
<wsdl:port name="Event" binding="aev:EventBinding">
<soap:address location="http://YOUR_CAMERA_IP/vapix/services"/>
</wsdl:port>
</wsdl:service>
And the service was generated.
I am trying to generate the client code from a WSDL.
I need to work on the Jdeveloper 10g IDE.
I generated client code from WSDL using the inbuilt tool Oracle JAX-WS 2.1.5.
For a particular WSDL this tool is generating around 122 java classes that does not include the Locator class. While running the code, I get a class not found exception for WebServiceLocator class.
However, when I am using Apache Axis 1.4 ( Eclipse IDE ), it is generating 63 java classes and it also includes the WebServiceLocator class, but this is not generating all the required methods that are needed for authentication, though ,Oracle JAX-WS 2.1.5. is generating those methods.
I tried merging the java classes generated from Eclipse into Jdeveloper, but then I am getting a lot of errors related to method signatures.
Is there some particular reason why these two different tools are generating different client codes, and none of them complete?
This is probably a bit late, but for those running into the same issues, this might be helpful.
If you really want to use Axis 1.x authentication is done on your client class as follows:
MyLocator bindingService = new MyLocator();
bindingService .setPortEndPointAddress(myEndpoint);
MyPort port= bindingService.getMyPort();
((Stub)port)._setProperty(Stub.USERNAME_PROPERTY, myUsername);
((Stub)port)._setProperty(Stub.PASSWORD_PROPERTY, mPassword);
//Perform your query here
I would personally use JAX-WS. Use wsimport to generate the stubs (SOAPUI has a nice plug-in to simplify this). For authentication on a JAX-WS client its easiest to save the wsdl locally and export it as part of the jar then load it in the client. This removes the need for HTTP authorization required to access the wsdl in the first place.
URL myWsdlUrl = getClass().getClassLoader().getResource("wsdl/myWsdlFile.wsdl");
MyService service = new MyService(myWsdlUrl , new QName("uri", "localpart"));
myPort port= service .getPort();
BindingProvider bp= ((BindingProvider)vPort);
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, myEndPoint);
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, myUsername);
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, myPassword);
//Perform query here
I have to consume a WCF web service and was given a WSDL (external, so have no control on the WSDL). Inside the WSDL definitions I am not finding the service element which has the service, port and address elements. Is that normal not be present in a WSDL? Is this common for a WCF WSDL? I am trying to generate stubs for this using axis and am having issues.
<wsdl:definitions>
....
...
..
**<wsdl:service>
<wsdl:port>
<wsdl1:address/>
</wsdl:port>
</wsdl:service>**
</wsdl:definitions>
The part between the asterisks is what is missing in the WSDL.
Did someone have an issue like this? Please let me know.
When generating stubs, I am getting this error:
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: Error parsing WSDL
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.(CodeGenerationEngine.java:175)
at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
Caused by: org.apache.axis2.AxisFault: No services found in the WSDL at file:/c:/work/xxx.wsdl with targetnamespace http://tempuri.org/
at org.apache.axis2.description.WSDL11ToAllAxisServicesBuilder.populateAllServices(WSDL11ToAllAxisServicesBuilder.java:115)
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.(CodeGenerationEngine.java:169)
... 2 more
I looked at the code WSDL11ToAllAxisServicesBuilder.java and it looks like this error occurs if axis does not find a service element.
Does anyone have a solution to this?
I found why this WSDL was missing the service tag, the original WSDL provided had an import which has the service element. I don't know if it is a correct way to do it or not, but the endpoint give to me to consume did not have it, I had to dig into other imported WSDLs to see that one of them had the service element.
Hope this helps someone.
I could not use a wsdl2java on the WSDL since there was no endpoint, do not know how to tell axis to look into the imported WSDLs for the service element though.