Retrieving WSDL for a single operation - java

Im a Newbie in wsdl parsing and my information about WSDL is very limited.
I have a scenario in which there is a wsdl file with multiple operations and i want to get the wsdl for a specific operation from that. Is there any libs in java or JS to accomplish such a task . Or am i missing something.
Please correct me if there is anything wrong in the question ,
Thanks in Advance
Bijesh

WSDLs represent a single service with specific operations. Those operations belong to the service can't be separated from the service itself. In order to simply invoke one method you'll have to bind against the entire service (and all other operations and defined types). If you are publishing the operation, you'll have to bind and publish all operations and types defined in the service. There isn't really a way around that.
Now, in your case if you are using java and if you are acting as a client, you can do what Alfredo O alluded to and use a SOAP framework's tooling to generate all of the java client code for you. From there it's just a matter of using the actual service class and invoking the method on that class that corresponds to the method you want to call. You'll have to use the entire wsdl, but from the perspective of your code you won't have to worry about calling any other methods than the one that interests you.
Popular choices for generating a java client for a SOAP service are:
Apache CXF
Metro
Apache Axis2

You can use Axis 2 to auto-generate the java code needed to invoke those operations. Use the wsdl2java tool provided by Axis 2.

Related

Python 2.7 : Where is wsdl file stored?

I want to create a Python RESTful Webservice and Java Webservice Client. I am using Python 2.7. I used web.py to create webservice. On client side (Java) , I want a WSDL file to invoke Python Webservice. Where can I find it? I have configured everything on my laptop.
Update: I refer Python simple example and this doesn't creates it.
Thanks !
Looks like you can always generate a url for the .wsdl file like in this example.
I simply created org.apache.http.client.HttpClient in java to invoke this. Though, I am curious to know wsdl file location.
As #Avenet advised, you can use soaplib, which became rpclib, which in turn became spyne. So check that, please.
People usually use the opposite workflow - they create WSDL manually and than generate stubs of code, so you have a good start, which you than extend with your business logic. Advantage is that it can generate both client and server stubs.
But both workflows should work - generating WSDL from a service, or generating code stubs from a WSDL. For learning purpose I would advice you to create WSDL manually.

Webservices / dynamic class generation / flow

My question probably sounds all wrong since I'm not sure what to ask exactly. I'm very new to web services in general but get a very high level idea. I'm looking at some code where the classes/methods are annotated and exposed for service calls.
The wsimport command can be used to call the http://.....?wsdl which it looks like dynamically generates these the client classes. I do not see a specific WSDL file so i'm guessing the JAX-WS is creating and sending the client source code to the client whcih downloads it and compiles it to the respective classes.
I notice some difference in the client generated class and the original server side class such as the missing toString() method and equals() method. Trying to read about this suggested something about custommized JAXB bindings and stuff. My questions are:
Does anyone know and can share information that gives a better
understanding of the kind of process I'm seeing. i.e. how the
annotated methods are magically appearing on the client side as part
of their respective classes?
Regarding the JAXB binding most of the websites begin from an
existing WSDL. How does this fit into my current problem?
Thanks

Accessing a remote service in Java through it's web interface using JAX-WS for SOAP

I have a public EJB class that I want accessible online as a web service. I have generated a WSDL and the SOAP mesasging seems to work. I used soapUI to test the connection. What I'm not clear about is how would I then use this exposed web service. I'd like to try another language like Python to then make calls through that interface. I know that the WSDL is supposed to help a potential client build it's client side code but I'm not sure about how to specify the connection and location and login information if I had that. I know I'm asking a large topic but any information would help. Thanks
Edit: so basicaly I'm just wondering do I have to use tools to generate my client code from the WSDL like axis2. Or whatever Python uses. Or can I write the code by hand? What's generally done. is the server reference included in that WSDL and are call methods generated usually?
Take a look at ZSI
But ZSI is too complex and spends more time to generate proxies
I suggest you to use suds. suds generates the proxies On the fly and so fast, i used it in some projects.
another packages are available:
soaplib
SOAPy
pysimplesoap

expose JAXB generated Class as WSDL web service

I have a bunch of very simple functions.
Each function has one input and one output.
OutputType function func(InputType);
The types of input/output are defined in xsd schema and generated into java classes with JAXB/XJC. Now I want to expose those functions as WSDL Web service running on Geronimo.
I just took a look at Axis/WSDL2Java/Java2WSDL; I thought that is pretty in a similar way as my functions are created.
I guess, I can use Java2WSDL to generate WSDL from my function and input/output types.
and then use some tools to generate server/client side binding,
Can anyone give more further suggestions? especially I have defined my input/output of functions in a xsd schema.
thanks very much.
A Summary:
These are what I have now....
Many implemented functions with one input and one outout.
public OutputType functionXXX(InputType in) { ....; return output; }
InputType and OutputType are already defined in a xsd schema (and turned into java classes with Jaxb/xjc).
What I want is....
Build Web services to execute those functions.
Not to touch the code of implemented functions.
And with WSDL,
I found a tutorial using CXF to do what you are looking to here.
That document claims to be using a contract first approach, but it isn't exactly. When discussing SOAP-based services, contract first means creating the descriptors (WSDL, XSD) first. You then generate any code artifacts from those descriptors. You can see the comments in the original blog post for the debate about the original author's choice of words.
That being said, a contract first approach has many benefits depending on what you are trying to accomplish. See the Spring Web Services tutorial for some information about it.
If you have an existing schema, with existing JAXB2 bindings for it, then in my experience Spring WebServices is by far the easiest way of exposing that as a SOAP web service. Its philosophy is "contract first", which is is exactly what you have. You don't need to generate any additional bindings, just wire up the endpoints a la Spring MVC, plug in the marshaller, and of it goes. It will introspect your schema looking for things that look like operations and expose them as WSDL operations automatically (you can tell it how to do that, if the default auto-discovery doesn't quite work).

What is the best way to expose a WCF service so that it can be easily consumed from Java/CXF?

We've written a WCF service to be used by a Java shop, who is using CXF to generate the adapters. We're not that familiar with Java, but have exposed the service using basicHttpBinding, SSL, and basic authentication. Integration tests show that a .NET client can consume the service just fine. However, the Java shop is having trouble consuming the service. Specifically, they getthe following JAXB error: Two declarations cause a collision in the ObjectFactory class. This is usually caused if 2 operations have the same name and namespace when CXF attempts to create adapter classes.
We can't find any type or operation names that should cause any sort of collision. We have made sure that all custom types specify a namespace, and tempuri.org is not specified anywhere in the WSDL. The Java shop suspects the error is because the generated WSDL contains <xsd:import elements.
So, my questions:
Is there any better way than CXF for the Java shop consume the WCF service? Project Tango looks interesting, but I don't know enough to tell them to consider using it. Is CXF a defacto standard in Java?
BasicHttpBinding/SSL/Basic Auth are MS recommended for interop scenarios, but the client still seems to have interop problems. Should we consider other bindings or settings to make this easier to consume?
Is there a way to configure WCF to always output a single WDSL with no schema imports?
The "Two declarations cause a collision in the ObjectFactory class" error message usually has nothing to do with imports. That's a JAXB error message that is usually caused by having multiple elements or similar that cause the generated field names to be the same. For example, if you have elements like:
<element name="Foo" .../>
and
<element name="foo" .../>
That can cause that error. Another is using thing like hyphens and underscores and such that are usually eliminated+capped:
<element name="doFoo" .../>
and
<element name="do_foo" .../>
With 2.1.4, you can TRY running the wsdl2java with the -autoNameResolution flag. That SOMETIMES helps with this, but not always. Unfortunately, the information that JAXB gives in these cases is nearly worthless and lots of times it's just trial and error to find the conflicting types. :-(
I am deep into Java & WCF interoperability. As someone else said you need to flatten your WSDL if you are working with file based WSDL. However I use Netbeans 6.5 and if you point to a real url like http://myservice/?wsdl , Netbeans can cope easily with the default wsdl generated by WCF.
In real life other things you need to consider is service versioning, optional datamembers (doesn't go well in java, so I suggest to make all datamembers IsRequired=true), order etc.
The real tough thing to get going was security. I had to make mutual certificate authentication working and it still has some issues.
The only way for your java client to talk to a WCF component will be one of the HTTP methods - basicHttpBinding, ws*, etc just as MS recommends. Java can't talk to WCF over TCP or namedPipes or MSMQ, etc.
I'd start with a super simple WCF component - something with a single method that spits out a string. Get that working with Java and then work your way up. Make sure that everything you're exposing is working with base types or well defined [DataContract] objects.
I've developped WCF with Axis2 clients. The authentication methods I've sucessfully uses is BasicHttpBinding/SSL/Basic (Transport) and WS-Security with Username (and MTOM).
The Metro implementation is used by SUN and Microsoft to test the interop :
http://weblogs.java.net/blog/haroldcarr/archive/2007/11/metro_web_servi.html
Sorry no clue about the import generated by WCF for the schema definition.
The problem with xsd:import is very common. Some toolkits or runtimes cannot cope with that. To address this, you can flatten the WSDL that is generated by WCF.
Check this post.
Regarding whether CXF is the right Java stack - I have never heard of it? I have used AXIS successfully, as well as JAX-WS. Both have been pretty straightforward.
This is a Jaxb issue. I ran into the same issue but used the xmlbeans option instead in wsdl2java client generation. To be honest I seem to prefer the xmlbeans objects more over jaxb as far a consumer to this webservice.

Categories

Resources