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 IndexWebSphere Message Broker SupportConverting mbelement to dataObject JCN node

Post new topicReply to topic
Converting mbelement to dataObject JCN node View previous topic :: View next topic
Author Message
Harsha_AS
PostPosted: Thu Jun 22, 2017 8:31 am Post subject: Converting mbelement to dataObject JCN node Reply with quote

Novice

Joined: 04 Dec 2011
Posts: 23

Hello,

I am facing an issue to convert mbelement to DataObject. Could you someone please help me on this. I am trying to cast here and at the run time i get it cannot cast mbelement to dataobject. Please let me know if there is any better way of doing it.

Below is the error i get at runtime.

Code:
"java.lang.ClassCastException: com.ibm.broker.plugin.MbElement incompatible with commonj.sdo.DataObject"

         MbElement inpayload=i n A s s e m b l y.getMessage().getRootElement().getLastChild();
         
             DataObject order = (DataObject) msgAsBytes;
         
         BOXMLSerializer serializer = (BOXMLSerializer) new ServiceManager()
                         .locateService("com/ibm/websphere/bo/BOXMLSerializer");
                 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                 String xMLString = "";
                 String returnStr = "";
                 String solrURL = "https://dev2-solr.ussco.com/solr-4.4.0/slicej";
                 try {
                     serializer.writeDataObject(order, order.getType().getURI(),
                             "order", outputStream);
                     xMLString = outputStream.toString("UTF-8");
                     Map<String, Object> options = new HashMap<String, Object>();
                     //options.put("convertdatetimefieldstoutc", true);
                     SOLRServiceFactory.getFactory(SOLRServices.OMSORDERS).newInstance()
                             .processRequest(xMLString, options, solrURL);
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Thu Jun 22, 2017 8:38 am Post subject: Reply with quote

Grand Poobah

Joined: 18 Nov 2003
Posts: 19156
Location: LI,NY

You are not dealing with a J2EE java server.
Look into what type of node will serialize automatically for you the message tree.

Use the facilities that come with the broker!.
Learn to use the broker Java API (see MbElement) class
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Harsha_AS
PostPosted: Thu Jul 06, 2017 10:07 am Post subject: Reply with quote

Novice

Joined: 04 Dec 2011
Posts: 23

Actually the issue is when we run the below code as a JAVA application we are able to send the data to URL - https://dev2-solr.ussco.com/solr-4.4.0/slicej.
But when I use the same code in IIB there is no data sent to the URL and it is not even throwing any error. Could some one please help me on this.

The above URL is not an webservice.

try {

xMLString = inputpayload;
Map<String, Object> options = new HashMap<String, Object>();
//options.put("convertdatetimefieldstoutc", true);
options.put("convertdatetimefieldstoutc", true);

SOLRServiceFactory.getFactory(SOLRServices.OMSORDERS).newInstance()
.processRequest(xMLString, options, solrURL);
//returnStr = "Order XML sent to SOLR:"+solrURL+"\n"+xMLString;
//System.out.println(returnStr);

} catch (Exception e) {
e.printStackTrace();
returnStr = "Error while sending message to SOLR ("+solrURL+") : \n"+e.getMessage()+"\nFor following Order XML\n "
+ xMLString;
//System.out.println(returnStr);
throw new MbUserException(this, "evaluate()", "", "", returnStr,
null);
//throw new MediationBusinessException(returnStr,e);
} finally{
System.out.println("Testing");
}
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Thu Jul 06, 2017 10:14 am Post subject: Reply with quote

Grand Poobah

Joined: 18 Nov 2003
Posts: 19156
Location: LI,NY

First let's try and explain what you're attempting to do.
Second if you are calling a web service, you should probably use a SOAP/REST Request Node and not do what you've shown us...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Harsha_AS
PostPosted: Thu Jul 06, 2017 10:24 am Post subject: Reply with quote

Novice

Joined: 04 Dec 2011
Posts: 23

No I am not calling the webservice. It is the SOLR service.

Do you think raising an PMR with IBM will help by any chance.
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Thu Jul 06, 2017 10:30 am Post subject: Reply with quote

Grand Poobah

Joined: 18 Nov 2003
Posts: 19156
Location: LI,NY

Harsha_AS wrote:
No I am not calling the webservice. It is the SOLR service.

Do you think raising an PMR with IBM will help by any chance.

And in which way is SOLR not a service? You access it through a URL and you pass it an XML? payload!
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Harsha_AS
PostPosted: Thu Jul 06, 2017 10:43 am Post subject: Reply with quote

Novice

Joined: 04 Dec 2011
Posts: 23

Actually we are migrating from WESB to IIB. We have just take the code from WESB and using it in JCN node. It works perfectly in WESB and also as a JAVA application but not in JCN node.

Yes er are accessing it through URL and pass it an XML.

SOLRServiceFactory.getFactory(SOLRServices.OMSORDERS).newInstance()
.processRequest(xMLString, options, solrURL);
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Thu Jul 06, 2017 11:25 am Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17267

There is a migration tool for moving from WESB to IIB.

You can't just slap a WESB application into an IIB JCN.
_________________
Read, Think, Try, Repeat
Back to top
View user's profile Send private message
Harsha_AS
PostPosted: Fri Jul 07, 2017 6:29 am Post subject: Reply with quote

Novice

Joined: 04 Dec 2011
Posts: 23

We have used the conversion tool. But it as not converted the Java code directly and it is commented out and it is asking us to write the code by ourself.

Any help will be great.
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Fri Jul 07, 2017 6:34 am Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17267

Harsha_AS wrote:
We have used the conversion tool. But it as not converted the Java code directly and it is commented out and it is asking us to write the code by ourself.

Any help will be great.


Okay.

What is the full error message you get in IIB?
_________________
Read, Think, Try, Repeat
Back to top
View user's profile Send private message
Harsha_AS
PostPosted: Fri Jul 07, 2017 7:30 am Post subject: Reply with quote

Novice

Joined: 04 Dec 2011
Posts: 23

Actually that is the issue I am facing. I am not seeing any error in IIB. It just terminates without any error but SOLR is not receiving any orders.
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Fri Jul 07, 2017 8:52 am Post subject: Reply with quote

Grand Poobah

Joined: 18 Nov 2003
Posts: 19156
Location: LI,NY

Harsha_AS wrote:
We have used the conversion tool. But it as not converted the Java code directly and it is commented out and it is asking us to write the code by ourself.

So what this is telling you is that you need to make the call to the SOLR service yourself.
Now as you should probably guess there is a reason why the Java code has been commented out...

Instead of the commented code, try introducing either an HTTP Request node, or a SOAP Request node, or a REST Request ...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Harsha_AS
PostPosted: Fri Jul 07, 2017 12:07 pm Post subject: Reply with quote

Novice

Joined: 04 Dec 2011
Posts: 23

Thanks for the time and response.

Actually it worked the same Java code.

One thing I did is, I added all the required certificates to keystore file since we are making an https call. And also worked with WESB team to use the correct jar files.
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Fri Jul 07, 2017 12:28 pm Post subject: Reply with quote

Grand Poobah

Joined: 18 Nov 2003
Posts: 19156
Location: LI,NY

Harsha_AS wrote:
Thanks for the time and response.

Actually it worked the same Java code.

One thing I did is, I added all the required certificates to keystore file since we are making an https call. And also worked with WESB team to use the correct jar files.

Good for you. However you have now circumvented the "official" way to do things. It is the most efficient way to do them as well. May be not the easiest as far as migration goes... but in 2 years who is going to maintain that??
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportConverting mbelement to dataObject JCN 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.