WebServices client in java? - web-services

I would like have a solution for creating a WebServices client and it needs to consume the Services which already existed.
I have code this from Netbeans ide but my requirement is the wsdl url must be a dynamic one and more specific it needs to fetch from .xml,please suggest me to do that dynamic..cheers

If you are building a Java EE application you can create a web service client in Netbeans. Otherwise you need to code it on your own or use a external tool or library.

You need to parse the XML and read the WSDL URL from it, you can find in the net for how to read the data from the XML
Once done,using the URL you got from the XML you can call the service endpoint (The code you have already)

Related

Document about calling webservice in jsf

I create a simple jsf page, i want to call webservice in jsf, but i can't find document which wrote about webservice in jsf. Can you give me some link about it? thank for your helping
If you need to call a published soap-WS (i.e: wsdl is online) inside your code you should create a ws-client for example with the wsimport tool (comes with JDK). this will give you a java client that you can use to communicate with the WS (even an EJB will simplify your work). From the jsf perspective you are still using a Pojo, so, the client could be injected in a #ManagedBean.
About how to generate a ws-client: http://ayazroomy-java.blogspot.com/2013/07/using-wsimport-tool-to-generate-client.html

SOAP Web Service basics

am new on WS.
some simple questions in my mind, please try to solve it.
i did a demo WS for Calculator on calculator(), where it has one UI where i enter values for it, internally pass it to WS. Ok i got answer/output. but if i want to create only webservice which take/give xml data or just give xml data. how can i create it.
i found some WS URL's about some fame company. is it used by using by opening Connection. how they define this URL? am using MyEclipse10 when i went to create new WS, needed to use Java Bean class for create it. ok, if i create myWS url then how it ll get call? because it is JavaBean?
and if just want to create WS then i need not required to create New WS client?
i dont know it is simple or may be foolish question, when i walk on WS i stop here. i feel like , without basic knowledge started to build it.
please, clear it.
Thanx.
MyEclipse (as well as Eclipse, IBM D Developer, etc) let you create a Java Web service server in one of two ways:
Bottom up Java Bean: you supply a bean, it turns it into a WSDL (and generates the corresponding stub code)
Top down WSDL: you supply a WSDL, and it generates the corresponding stub code
When a company creates a web page, they set up a web server and publish some HTML pages on it.
When a company publishes a WSDL, they also set up a web server ... and publish an XML WSDL on it.
The URL you go to in order to read a WSDL is just an ordinary HTTP web server, that happens to be serving an XML WSDL at that location.
The WSDL specifies where the service can be found, and what operations and data types the service uses. A WSDL you create, or a WSDL that's published by some other company.
'Hope that helps

calling web services from UNIX

I have a requirement to kickoff a workflow which is in salesforce.com thorugh web service from UNIX box. Can any one suggest me options or guide lines to achive this scenario?
I don't think you can just "kick off workflows". You'll have to perform an insert or update of records in Salesforce that will satisfy the workflow's entry criteria.
There's a Java tool called Data Loader for your basic data manipulation activities (you can download it from your own production org)
and it can be scripted for scheduled runs, has config file where you can store user's password in secure way etc. Check out the pdf guide for more ("Command Line Quick Start" chapter)
So I don't think you really need a webservice call...
Unless I misunderstood and you're talking about calling an Apex class' method that has "webservice" keyword and it will somehow perform the updates?
In that case you'll need to download the WSDL file generated for this class (Setup->Develop->Classes) and well, consume it in language of your choice (Java, PHP, Python... this link will help, steps aren't too different), then do your command line magic?
http://wiki.developerforce.com/page/Integration has tons of resources for you :)
Salesforce uses SOAP for their web service. They don't have restful web services now. Just request them to give the wsdl file.
Use this wsdl file to generate the java code. After that get their webService url so that you can proceed with your data pulling
This link may help you..
http://salesforce-walker.blogspot.in/2011/12/to-access-salesforce-data-from-java-we.html
Hope this helps

Generate WSDL for existing SOAP Service using captured traffic

I need to use the SOAP service of a printer. There is a windows tool to access this service and I used it to generate SOAP requests and responses of the important functions that I need.
Now I should write a client for Linux using Python and I found the easiest way would be to use the suds library with an WSDL file. But I don't have this WSDL!
As I investigated the windows tool (looked at the hexdump of the executables), I came to the conclusion that there probably is no WSDL file at all.
Now my question is, has anybody experience with "reverse engineering" SOAP services and knows tools which could be useful for creating WSDL files for existing services? (Googleing hasn't brought up anything useful yet).
You mentioned this is the SOAP service of a printer. Is the printer's API documented on the manufacturer's site? Does the documentation include the WSDL? Can you get the WSDL from the manufacturer?
If you can get the WSDL from the manufacturer then you're done!
If not, then you have to build the WSDL by yourself because I doubt you can find a tool that generates WSDLs given SOAP samples (when working with SOAP web services you mainly get two kinds of tools: those that generate code from WSDL + those that generate WSDL from code).
It's not hard to create the WSDL if you are familiar with SOAP, WSDL and XSD. You just need a text editor or maybe even a WSDL editor to speed things up.
If you don't have full confidence in your WSDL knowledge, there are still some tools that can get you most of the way to the complete WSDL. Here is a way you could do it:
1 - First you need to create the XML schema for the SOAP payloads. For this you can find tools, even some online. After you have the schema, tweak it to your needs by adding, changing or removing elements.
2 - Now you can use the XSD to generate a WSDL. There is an online tool that does that. It just needs the request/response element types to end with Request/Response. Make sure you read the instructions.
You take your XSD file, change the names of the operations to add the Request/Response suffix and feed it to the WSDL Generator - Web Tool. You will get your WSDL.
Now tweak this WSDL as you like (remove the Request/Response suffixes if you don't need them) then ...
3 - ... make sure you end up with a valid WSDL.
4 - Now you can take your WSDL and use a tool like SoapUI to generate sample requests and responses from it just to verify that you get the proper results back.
Do the SoapUI messages match the messages you started with? If yes, you are done and can feed the WSDL to suds to create the Linux client. If not, tweak the WSDL until you get the result you are after.

Using Biztalk orchestration as a webservice

I published an orchestration in Biztalk as a webservice. Does anyone know how I can use XML serialization or something to load XML from a file and "convert" it to the messagetype the webservice expects? How do people usually use this webservices? I try to avoid using untyped messages since I use both XML and flatfile, and have read that it could mean trouble.
Well, I guess generally the idea of web services is that you add a web reference to them, which would generate a set of proxy classes you could use to interact with the web service.
You don't normally have to worry about serialising xml files to and from the web service formats, the generated code will do it for you.
If you do wish to, however, to work of XML, you could use .net serialisation to deserialise an xml file into the generated proxy type (as well as serialise any response you're getting).
Here's a basic example of how to deserialise xml into a class instance, you can then pass this instance into the method in the generated proxy.
System.Xml.Serialization.XmlSerializer xser = new System.Xml.Serialization.XmlSerializer(typeof(<generated request type here>));
xser.UnknownAttribute += new System.Xml.Serialization.XmlAttributeEventHandler(xser_UnknownAttribute);
xser.UnknownElement += new System.Xml.Serialization.XmlElementEventHandler(xser_UnknownElement);
xser.UnknownNode += new System.Xml.Serialization.XmlNodeEventHandler(xser_UnknownNode);
xser.UnreferencedObject += new System.Xml.Serialization.UnreferencedObjectEventHandler(xser_UnreferencedObject);
<generated request type here> request = (<generated request type here>)xser.Deserialize(<xml stream here>);
I hope that makes sense
You question is bit confusing. You started off with saying you published an orchestration as web service, but raised the question about consuming it.
If you are talking about published web service:
The web service generated by BizTalk Web service Wizard is not different from a web service you would have written in .NET. Based on the message type you orchestration is expecting and how your structured the operation in the wizard. The Wizard would have auto generated a webservice for you with WSDL and schemas (there will be some BizTalk specific bits inside, but you don't need to worry about the implementation).
You consumers (independant of platform) should be able to consume that web service without any major issues.
If you are trying to consume a web service from Orchestration
Have a look at this paper http://msdn.microsoft.com/en-us/library/ms935219(BTS.10).aspx