Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@manish-r2Hoep • Nov 2, 2009
What kind of web services do you want in any application sookie??? -
@sookie-T06sFW • Nov 3, 2009
Hey goyal420, thanks a lot for the reply. I already have some Web Service API ready and also have WSDL[Web Services Description Language]. I jus want to know what all steps one need to take for binding that wsdl in any application. I know one can call that Web services API method's in the application but what configurations one need to do for that.goyal420What kind of web services do you want in any application sookie???
In other way, I want to know the entire flow of working of Webservices
PS: Any kind of help will be appreciated in this regard . Thanks a lot ! -
@CrazyBoy • Nov 3, 2009
If you are interested in binding part then do the following:
WSDL – <binding> element
- Tie the <portType> element to the protocol defined for the binding.
- Define the transport protocol and style (RPC or Document).
- For each operation of the <portType> each <message> needs to be detailed.
- For SOAP, the <soap:body> element needs to be defined, use (encoding or literal) and namespace.
- If using encoding, <soap:body> needs to specifiy encodingStyle.
Do let me know If you need anything specific.
-CB -
@sookie-T06sFW • Nov 3, 2009
@crazyboy Thanks a lot that was really something informative response.
One question, if I have that part of binding in my WSDL document then how can I call the methods[or to be more precise called as 'operations' in Web Services world] in my applications web pages ? Is it possible to do anything like that ?
I am having two servers - First on which my current application runs[Can call it as Service Consumer] and Second is on which some other server is running providing some services [can be called as Service provider]. The Second server provides some services defined in a WSDL document. Now I want that WSDL to be found by First server [Service Consumer]
Can you give some ideas about it ? Rest of the part I will do. I just need some ideas about all this working concept. 😕
[EDIT]
One more thing, Do I need to create any proxy and stub sort of classes to call that service in my application or is it possible without using them also ?
Thanks a lot ! -
@sookie-T06sFW • Nov 5, 2009
Hi everyone
Thanks a lot for so much of your help. My problem is sort of solved. 😀
We can consume web services in an application by using #-Link-Snipped-#. I am simplifying the steps and writing them down here
STEP 1: Download separately[or can include them directly form Axis bin/lib folder if Axis is installed] and include following jar files in the CLASSPATH of your Client Class [Class which will consume services]
- axis.jar
- jaxrpc.jar
- saaj.jar
- commons-logging.jar
- commons-discovery.jar
- wsdl4j.jar
STEP 2: Download the WSDL file from Service Provider server's url For.eg. #-Link-Snipped-#
Add File with extension as .wsdl in your project. Let me name above WSDL file as StockQuote.wsdl
STEP 3: Now create stub classes using following command at run time. Go to appropriate structure of your project's folder and enter following command in Command prompt.
java -classpath D:\bin\axis-1_4\lib\axis.jar;D:\bin\axis-1_4\lib\jaxrpc.jar;D:\bin\axis-1_4\lib\saaj.jar;D:\bin\axis-1_4\lib\commons-logging.jar;D:\bin\axis-1_4\lib\commons-discovery.jar;D:\bin\axis-1_4\lib\wsdl4j.jar; org.apache.axis.wsdl.WSDL2Java StockQuote.wsdl
STEP 4: Now you can simply create Client class like following and use the operations specified in your WSDL. You can also pass paramters.
import org.apache.axis.client.Call; import org.apache.axis.client.Service; import javax.xml.namespace.QName; public class TestClient { public static void main(String [] args) { try { String endpoint ="https://www.webservicex.net/stockquote.asmx?WSDL"; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress( new java.net.URL(endpoint) ); call.setOperationName(new QName("https://soapinterop.org/", echoString")); String ret = (String) call.invoke( new Object[] { "Hello!" } ); System.out.println("Sent 'Hello!', got '" + ret + "'"); } catch (Exception e) { System.err.println(e.toString()); } } }Finally, your work that you want to do using services is done. 😀
For basic flow of Web services , check #-Link-Snipped-#
PS: If any queries, Please ask- I may try to answer. -
@manish-r2Hoep • Jan 10, 2010
hey sookie can we consider this concept of web services similar to socket programming?I mean both are used for making connection and to retrieve the services..If i am right?If no can you please explain the difference?