ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Dynamically load a JAR in a Java compute node

Post new topic  Reply to topic Goto page 1, 2  Next
 Dynamically load a JAR in a Java compute node « View previous topic :: View next topic » 
Author Message
mehdiK
PostPosted: Fri Apr 19, 2013 8:16 am    Post subject: Dynamically load a JAR in a Java compute node Reply with quote

Acolyte

Joined: 07 Mar 2013
Posts: 53

Hello,

I have an external service which generates a WSDL file, After that a jar is generated (Client Proxy classes) and I have to implement the client which will load dynamically the jar to the classpath to consume the WebService.

So, I try to create a java code in a Java Compute Node which will load dynamically the external Jar.

Is it possible ? Do you have any idea about this ?

Thank you
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Apr 19, 2013 8:18 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

That's a lot of effort and work to avoid using a SOAPRequest node.
Back to top
View user's profile Send private message
mehdiK
PostPosted: Fri Apr 19, 2013 8:23 am    Post subject: Reply with quote

Acolyte

Joined: 07 Mar 2013
Posts: 53

Thank you.

But the SOAPRequest needs a setted WSDL, but I don't have a setted one, I may have many WSDL in a directory which are created dynamically by the external service.

SOAPRequest could do that ?

Regards.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Apr 19, 2013 8:34 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

SOAPRequest can act in a gateway/passthrough mode that doesn't require that it has a fixed, assigned WSDL, merely that the WSDL is actually deployed, or that enough of the XSDs are deployed such that the XML can be validated.

But regardless of all of that, you're asking how to call a service that is completely undefined at development time.

How do you write code to build a message when you do not know what message you are building when you are writing the code?
Back to top
View user's profile Send private message
mehdiK
PostPosted: Fri Apr 19, 2013 8:47 am    Post subject: Reply with quote

Acolyte

Joined: 07 Mar 2013
Posts: 53

Thank you.

I understand what you said about SOAPRequest.

The process is : IBM Forms creates a form and when it submitted and published it generates a WSDL File in a folder, and the broker receives an XML file (the message), it send it to an external SOAP Webservice (Following the WSDL).

So the SOAPRequest shoul always know which WSDL is used, to know which webservice is called.

That's why I thought that Java could do it.

Do I do something wrong ?

Regards.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Apr 19, 2013 9:05 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mehdiK wrote:
So the SOAPRequest shoul always know which WSDL is used, to know which webservice is called.


No, as my most worthy associate pointed out above, you can use any SOAP node in a gateway mode.

mehdiK wrote:
That's why I thought that Java could do it.


It probably could; you can do anything in custom code. The question is why would you when there's an alternative built in?

mehdiK wrote:
Do I do something wrong ?


Well you don't seem to have bothered to research the suggestion made in the earlier post about gateway mode.

I also echo the comment of my most worthy associate:

if the format of the message is not available at development time, how can you format the message to be sent (via SOAPRequest or via custom Java)?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mehdiK
PostPosted: Mon Apr 22, 2013 9:31 am    Post subject: Reply with quote

Acolyte

Joined: 07 Mar 2013
Posts: 53

I'm learning about SOAP Request node, but I've succeeded to load dynamically the jar which contains the proxy classes of the WebService Client and consume a Webservice.

Here's the code :
Code:

String filePath = new String("C:/Services/S-0-0-1/lib/ws-client.jar");
         
         URL myJarFile = null;
         try {
            myJarFile = new URL("file:///"+filePath);
         } catch (MalformedURLException e) {
            e.printStackTrace();
         }
         URL wsdlURL = null;
         try {
            wsdlURL = new URL("http://localhost:7801/McintWebservices/services/McintWebservicesPort?wsdl");
         } catch (MalformedURLException e) {
            e.printStackTrace();
         }
         
         QName SERVICE_NAME = new QName("http://ws.mcint.com/","McintWebservicesService");
         
         URLClassLoader cl = URLClassLoader.newInstance(new URL[]{myJarFile});
         
         Class McintWebservicesSEI = null;
         try {
            McintWebservicesSEI = cl.loadClass("com.mcint.ws.McintWebservicesSEI");
         } catch (ClassNotFoundException e) {
            e.printStackTrace();
         }
         Service service =  Service.create(wsdlURL, SERVICE_NAME);
         
         Method whatIsTheAnswer = null;
         try {
            whatIsTheAnswer = McintWebservicesSEI.getMethod("whatIsTheAnswer", new Class[] {String.class});
         } catch (SecurityException e) {
            e.printStackTrace();
         } catch (NoSuchMethodException e) {
            e.printStackTrace();
         }
         
         Object client = service.getPort(McintWebservicesSEI);

         Object response = null;
         try {
            response = whatIsTheAnswer.invoke(client, "Mehdi ");
         } catch (IllegalArgumentException e) {
            e.printStackTrace();
         } catch (IllegalAccessException e) {
            e.printStackTrace();
         } catch (InvocationTargetException e) {
            e.printStackTrace();
         }

I don't recommend use this , I use it just while I learn the SOAPRequest node.

Thank you.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Apr 23, 2013 5:31 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

And what if the JAR file you want to load does not provide a whatIsTheAnswer method?

How do you know what method to call, if you don't know what interface is provided by the service?
Back to top
View user's profile Send private message
mehdiK
PostPosted: Tue Apr 23, 2013 7:35 am    Post subject: Reply with quote

Acolyte

Joined: 07 Mar 2013
Posts: 53

The full process is :

When a agent creates a form (with a specific ID) in IBM Forms, a wsdl and a Jar are generated and stored in the disc in a directory which it's name is the form's ID, the jar contains the proxy classes of the webservice client.
The jar has also a name like : Jar_ID.jar and it's classes are like : Name_Class_ID.class or .java.

and IBM Forms sends an xml message to the Broker (REST), and this XML contains a field which contains the names's method and it's signature, so it will be possible to load dynamically the Jars and invoke the method.

Regards.
Back to top
View user's profile Send private message
mehdiK
PostPosted: Tue Apr 23, 2013 9:40 am    Post subject: Reply with quote

Acolyte

Joined: 07 Mar 2013
Posts: 53

I've just noticed about the method's signature, how am I supposed to know it..
Code:
whatIsTheAnswer = McintWebservicesSEI.getMethod("whatIsTheAnswer", new Class[] {String.class});
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Apr 23, 2013 9:48 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

mehdiK wrote:
I've just noticed about the method's signature, how am I supposed to know it..
Code:
whatIsTheAnswer = McintWebservicesSEI.getMethod("whatIsTheAnswer", new Class[] {String.class});


That's exactly the question we can't answer.

And exactly the question we've raised - how can you develop a SOAP call if you don't know at development time what SOAP call to make.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Tue Apr 23, 2013 11:35 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

mqjeff wrote:
mehdiK wrote:
I've just noticed about the method's signature, how am I supposed to know it..
Code:
whatIsTheAnswer = McintWebservicesSEI.getMethod("whatIsTheAnswer", new Class[] {String.class});


That's exactly the question we can't answer.

And exactly the question we've raised - how can you develop a SOAP call if you don't know at development time what SOAP call to make.


The whole premise of SOAP "Simple Object Access Protocol" is to define a contract between a service producer and a service consumer. Based on this contract, you write "develop" source code.

If the contract changes, the contract for both is broken until both the producer and the consumer update their source code to the new contract.

Your lack of knowledge is a great hindrance to you, since this fundamental principle is essential to successfully using SOAP and WSDLs. Read more on the topic or attend the required training.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
smdavies99
PostPosted: Tue Apr 23, 2013 10:34 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

lancelotlinc wrote:


The whole premise of SOAP "Simple Object Access Protocol" is to define a contract between a service producer and a service consumer. Based on this contract, you write "develop" source code.



SOAP = simple....

Yeah right. There a good number of alternative words I could use all starting with 'S' that reflect my opinion of it.

One large US company I have been working with stated in their documentation that 'communication with their system requires the use of the SOAP protocol'. Ok we said, where's the WSDL and XSD?
What? What do you mean by WSDL?
I pointed them to some suitable web sites. They replied
We don't have them. We don't know how to create them.
What they really meant was that they required XML messages (xsd unknown) to be wrapped in a SOAP envelope (WSDL unknown).
So do you really think the the 'S' stands for Simple?

I know that this is a bit but sometimes people/companies jump on a bandwagon when I'd really like to them
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
goffinf
PostPosted: Tue Apr 23, 2013 11:29 pm    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

smdavies99 wrote:
lancelotlinc wrote:


The whole premise of SOAP "Simple Object Access Protocol" is to define a contract between a service producer and a service consumer. Based on this contract, you write "develop" source code.



SOAP = simple....

Yeah right. There a good number of alternative words I could use all starting with 'S' that reflect my opinion of it.

One large US company I have been working with stated in their documentation that 'communication with their system requires the use of the SOAP protocol'. Ok we said, where's the WSDL and XSD?
What? What do you mean by WSDL?
I pointed them to some suitable web sites. They replied
We don't have them. We don't know how to create them.
What they really meant was that they required XML messages (xsd unknown) to be wrapped in a SOAP envelope (WSDL unknown).
So do you really think the the 'S' stands for Simple?

I know that this is a bit but sometimes people/companies jump on a bandwagon when I'd really like to them


Well the 'S' in SOAP hasn't meant 'Simple' for quite a few years neither are any of the other letters substitutable. Interestingly there are some proponents that believe that XSD free specification is a better approach, indeed at the Basilage conference this year there is a paper the proposes that XSD is actively harmful to flexible interchange. I'm not saying I personally agree with that premise but it is definitely not without a strong logical foundation, and of course there are many alternate exchange formats. If you want to follow that debate, pop over to the XML-Dev forum.

But again off topic.

Fraser.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Wed Apr 24, 2013 3:16 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

I think thats why REST is gaining popularity, as it can be used without a contract. I agree with both of you that complexity is gaining when using XSDs; however, well-defined Web Services are working well in business environments.

You get value from XSDs equivalent to the effort that was put in to write them, which includes extensive commentary and documentation embedded within the XSDs. One example of poorly written XSDs is numeric enums when well-formed descriptive enums are just as easy to include.

@smdavies, like your new picture.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Dynamically load a JAR in a Java compute node
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.