I am trying to consume a java web service from .NET.
When I add service reference to generate proxy and run the programme i get the error below
The formatter threw an exception while
trying to deserialize the message:
There was an error while trying to
deserialize parameter
http://order.x.service.y.com:requestPayment.
Apparently I have to tweak the proxy classes generated bacause of differences in namespaces between JAVA and .NET but am not sure how.
It sounds like the java web service has at least some non-interoperable features.
Do you have access to the java web service code? If so, maybe you can create your own proxy class that can talk with it. I would not try to change the auto-generated proxy code. I'd suggest hooking up to the java web service manually instead of by adding a Service Reference.
Although this article is geared mainly to consuming WCF services, it goes into some depth in consuming services manually. You'll be able to follow most of the steps for manual proxy connection even though you're pointing to a java service.
Related
I have wsdl
http://www.webservicex.net/genericbarcode.asmx?WSDL .
I am trying to create a client, looking for logic in wsdl.
I think it should start from this:
BarCode barCode=new BarCode();
BarCodeSoap barCodeSoap=barCode.getBarCodeSoap();
Do I need to input any parameters there?
Executable code is generated from WSDL of the Webservice. The client then uses this code to access the Webservice.
For example, GlassFish includes vsimport utility to generate Java code from WSDL.
This utility generates a lot of compiled Java classes that allows client applications to access to Webservices. These classes are further to be added to classpath of the client.
In addition, GlassFish includes custom Ant task (also there are Maven plugin for that).
Then you need to use #WebServiceRef annotation that inject the instance of the Webservice to you client.
#WebServiceRef(wsdlLocation="...?wsdl")
private static NameOfYouServiceService nameOfYouServiceService;
...
NameOfYouService - this is convention, the name of Webservice that you develop.
Then this call nameOfYouServiceService.getNameOfYouServicePort() return you instance of the Webservice. Then you can free use methods of the instance.
Here, the name NameOfYouService - also convention.
In short, something like that.
Your Webservice is written in .NET technology, but you can also using Java client (or PHP or something else) to access it. In fact, a web service created with one technology can be accessed by clients in any other technology.
Here is a good article for your case: Java Client for WebServiceX.Net Web Service (NetBeans IDE)
I wrote a java web service on Netbeans 6.9.1 and deployed on GlassFish 3.0.1
I have a wsdl url like this "http://localhost:8080/web2/service2Service?wsdl".
How can I use this url to access this web service from another java application.
Thanks
You need to generate some Java that represents the client's view of the Web Service and then invoke that Java. Here's an article which explains some of the detail.
Generating client from WSDL in Eclipse
The general idea is that you generate some Java classes from the WSDL. Those classes act as a proxy for the service you want to call. Your java invokes methods on the proxy objects, the generated code creates the appropriate SOAP messages, sends the HTTP request, interprets the response and your code just sees a Java result.
I just use the tooling built into Eclipse, but you will also find other suitable generators, for example in Apache's Axis
1º U must save the content in a "myWebServices.wsdl" file
2º Run your Wsdl converter, all compilers have one of this, normally the name is WDSL.EXE
This process will create a new file with NameSpace or Package with the definitions of webservices built in.
3º Then imports this package or built a library.
Develop web service Client in second application.
You can use Netbeans to create web service client by giving your wsdl url
The document at this url is the actual wsdl (a description of the actual webservice, written in WebService Definfition Language).
The description includes information about the services url, the protocol(s), the method names and and data objects. Your application will use that information to call the remote methods of that service.
The protocol may or may not be SOAP, and without knowing the webservice details, it's quite impossible to recommend a toolset or methodology to use the webservice, there is no general approach. In most cases we see SOAP, for those services I recomment soapUI as a general tool to use and test SOAP based webservices and apache axis to implement java based service consumers.
In most tutorials that I have seen so far people are using wsconsume or something like that to create classes that clients can use to access an EJB 3 Web Service.
Is this the only possible option? As my EJB's interface is annotated with WebMethod, WebParam, etc. isn't it possible to create a dynamic proxy or use runtime bytecode enhancement to create the proxies, etc. on the fly? E.g.:
MyWebService webService = WebServiceEnhance.getWebService(MyWebService.class);
webService.webMethod("foo");
A link to good reference material is also highly appreciated.
One way is to deal with pure XML request/response. You can trap sample request/response for the web service you want to consume using either SoapUI or Fiddler and then use these samples as templates within your client.
I am migrating a Java RMI application to Java Web Service (school assignment) and I've encountered an issue...
Currently my Java Server creates an instance of the Remote Object, this object has a constructor and takes a parameter (int ID) which tells it which database to load in memory - works like a charm ...
Now, migrating this to Web Services is causing my a problem - first I needed to add a default constructor because it wouldn't deploy without it, and then while doing some reading all these discussions about "stateless web services" kept coming up ...
For example, if I "start" my webservice with parameter(0) it would load from Databse 0 and all requests from Clients would be done using that data... I want this to only happen when I start the WebService and NOT everytime the client connects... Loading from the DB is expensive and takes time, so I want to do it once so that clients when they connect just deal with the data in memory ...
This is how it works with my Java RMI .... but can this also work with Web Services?
Any advice would be much appreciated.
Thanks,
Perhaps you should consider splitting your presentation from the backing service. Consider the WebService simply a presentation layer and the database processing the service being presented. The web service should really just be referencing the database via a handle to a single instance rather than actually being that instance. This means that the "state" is then held in the database instance not the web service.
One way to consider this (although I would not suggest that you implement it this way) is to consider the Web Service as the RMI client of the database rather than the RMI server service.
Hope this helps.
Kind regards,
Malcolm
I'm developing a Web Service Project in which I have to implement a web service that should be interoperable on all platforms. So initially I used basicHttpBinding as it uses SOAP 1.1 but I want the features of WS-* like reliable messaging, security, exceptions. So I used wsHttpBinding which is a SOAP 1.2 standard.
Now after deploying on my test server I used Netbeans IDE to generate a webservice client. So in return it called the wsimport tool in java to generate proxy classes. When I invoke any method it simply goes into non-working state like there is no activity for 5 mins. So I'm not able to figure out that whether Java client can consume a SOAP 1.2 web service created in WCF?
I need to know if I need to use any other binding than wsHttpBinding for all the features and have interoperability as well.
I don't get any error when i invoke the web method.I tried debugging it but to no help.i set break-point on the line which was invoking the method,when debugger reaches that line then nothing happens, IDE shows running status but there is no activity.If anyone can suggest a tool to monitor Http request to server.
Have you tried tracing the communication between the Java client and the WCF service?
I would do two things first, turn on logging in WCF; use a trace tool (there are many tike tcptrace) to act as a proxy between the client and server, then point the client at the trace tool and the trace tool at the server. That way you get to see the traffic and the XML (if any) sent back and fore. That should give you a much better idea as to what is going on.
Why not configure another endpoint using SOAP 1.1?