Hi,
We are facing an issue when trying to get the result from request reply integration.
We are getting the reply event as a string.
But we want that to be converted into a storage class. We are not able to convert it due to issues and restrictions in webMethods.
Any suggestion is greatly appreciated.
My storage class for the reply events are:
- TOP LEVEL
package com.gepower.geps.common.eai.data;
import com.gepower.geps.common.eai.data.Line;
public class QueryPartLifeReplyDoc
{
public String ERROR_CODE;
public String ERROR_REASON;
public String ACCMFACHRS;
public String ACCMFACSTARS;
public String ACCMFHRS;
public String ACCMSTARTS;
public String ACCMTRIPS;
public String SITE_NAME;
public String HEADER_FLEX_FIELD1;
public String EVENT;
public Line Line;
public QueryPartLifeReplyDoc()
{
}
} - CHILD LEVEL (Line array in the above bean)
package com.gepower.geps.common.eai.data;
import java.util.Date;
public class Line
{
public String PART_DWG;
public String UNIT_NUMBER;
public String POSITION;
public String OUTAGE_DATE;
public String SERVICE_DATE;
public String DATE_ENTERED;
public String EVENT_TYPE;
public String IRS_JOB_NUMBER;
public String CURR_FACT_FIRED_HRS;
public String CURR_FACT_START;
public String CURR_ACT_FIRED_HRS;
public String CURR_ACT_STARTS;
public String CURR_TRIPS;
public String OUTAGE_TYPE;
public String OUTAGE_ID;
public String AVL_FIRED_HRS;
public String AVL_STARTS;
public String LINE_FLEX_FIELD1;
public String LINE_FLEX_FIELD2;
public Line()
{
}
}
After getting the reply using PublishRequestAndWait(), we are getting the results. Which we tried to convert to this data bean time. But we are getting error with this.
First method we tried is as follows:
Proposed Implementation:
We tried to get the databean from the replyevent by the below method.
Method Name: e1.toObject(objlQphReply);
But got the below error though “PART_DWG” exists in the line details. It is checking for some patern like “Line.PART_DWG”. Due to which it is giving error.
We tried to change the field name in the to this name in the broker. But this kind of naming convension is not allowed by broker.
Error Details
Error getting reply event
Field Not Found (203-1093): The field ‘Line.PART_DWG’ is defined in the storage class but is not defined in the document type defintion.
Field Not Found (203-1093): The field ‘Line.PART_DWG’ is defined in the storage class but is not defined in the document type defintion.
at COM.activesw.API.client.ReflectTypeDef.compareBasicField(ReflectTypeDef.java:1117)
at COM.activesw.API.client.ReflectTypeDef.compareField(ReflectTypeDef.java:1020)
at COM.activesw.API.client.ReflectTypeDef.compareStructField(ReflectTypeDef.java:1087)
at COM.activesw.API.client.ReflectTypeDef.compareSequenceField(ReflectTypeDef.java:1048)
at COM.activesw.API.client.ReflectTypeDef.compareField(ReflectTypeDef.java:1006)
at COM.activesw.API.client.ReflectTypeDef.compareStructField(ReflectTypeDef.java:1087)
at COM.activesw.API.client.ReflectTypeDef.compareTo(ReflectTypeDef.java:959)
at COM.activesw.API.client.ReflectTypeDef.getTypeDefInternal(ReflectTypeDef.java:639)
at COM.activesw.API.client.ReflectTypeDef.getTypeDef(ReflectTypeDef.java:599)
at COM.activesw.API.client.ReflectEvent.(ReflectEvent.java:106)
at COM.activesw.API.client.BrokerEvent.toObject(BrokerEvent.java:694)
at request3Test.main(request3Test.java:138)
Second method that we tried is as follows:
Proposed Implementation:
After getting the reply event, we used below broker method to get the line details. But we got the below error.
method used: e2 = events[0].getEventSeqField(“Line”, 0, -1);
Error Details:
Field Type Mismatch (204-1116): The field ‘Line’ must be a sequence for this operation.
at COM.activesw.API.client.BrokerEvent.getEventSeqField(BrokerEvent.java:5603)
at request3Test.main(request3Test.java:142)
Error getting reply event
Field Type Mismatch (204-1116): The field ‘Line’ must be a sequence for this operation.
Can you provide solution to resolve this issue?
JavaCode:
/*
- request3.java
- Copyright 2004 webMethods, Inc.
- ALL RIGHTS RESERVED
- UNPUBLISHED – Rights reserved under the copyright laws of the United States.
- Use of a copyright notice is precautionary only and does not imply
- publication or disclosure.
- THIS SOURCE CODE IS THE CONFIDENTIAL AND PROPRIETARY INFORMATION OF
- webMethods, INC. ANY REPRODUCTION, MODIFICATION, DISTRIBUTION,
- OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY PROHIBITED
- WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF webMethods, INC.
/
import com.gepower.geps.common.eai.data.QueryPartLifeReplyDoc;
import com.gepower.geps.common.eai.data.QueryPartLifeRequestDoc;
import COM.activesw.API.client.;
public class request3Test
{
// Set classpath=%classpath%;.;C:\temporary;C:\webMethods.jar
static String broker_host = “3.209.5.12:6849”;
// static String broker_host = “3.181.40.6:6900”;
static String broker_name = “Broker #1”;
// static String client_group = “PLDB_EPDM_Service_Request_Client”;
static String client_group = “IntegrationServer”;
static int num_requested = 10;
public static void main(String args)
{
BrokerClient c;
BrokerEvent e;
BrokerEvent events;
boolean can_publish;
boolean can_subscribe;
// boolean done;
String st;
RequestCallback sample_callback = new RequestCallback();
/* Check command line /
if (args.length > 0) {
num_requested = Integer.parseInt(args[0]);
}
/ Create a client /
try {
c = new BrokerClient(broker_host, broker_name, null,
client_group, “Request Sample #3”, null);
} catch (BrokerException ex) {
System.out.println(“Error on create client\n”+ex);
return;
}
/ Check if can publish /
try {
can_publish = c.canPublish(“wm::is::Canonical::QueryPartLife::QueryPartLifeRequestDoc”);
} catch (BrokerException ex) {
System.out.println(“Error on check for can publish\n”+ex);
return;
}
if (can_publish == false) {
System.out.println(“Cannot publish event Sample::Request”);
System.out.println(“Make sure it is loaded in the broker and”);
System.out.println(“permission is given to publish it in the”);
System.out.println(client_group + " client group.");
return;
}
/ Check if can subscribe /
/ Need can subscribe permission to receive the reply /
try {
can_subscribe = c.canSubscribe(“wm::is::Canonical::QueryPartLife::QueryPartLifeReplyDoc”);
} catch (BrokerException ex) {
System.out.println(“Error on check for can subscribe\n”+ex);
return;
}
if (can_subscribe == false) {
System.out.println(“Cannot subscribe event Sample::Reply”);
System.out.println(“Make sure it is loaded in the broker and”);
System.out.println(“permission is given to subscribe to it in”);
System.out.println(“the " + client_group + " client group.”);
return;
}
/ Create request event /
try {
e = new BrokerEvent(c,“wm::is::Canonical::QueryPartLife::QueryPartLifeRequestDoc”);
QueryPartLifeRequestDoc objlQphRequest = new QueryPartLifeRequestDoc();
objlQphRequest.PART_TYPE_ID = “GTTBRG002”;
objlQphRequest.PART_TYPE = “BUCKET STAGE 2”;
objlQphRequest.PART_SN = “C1GB094064”;
objlQphRequest.PART_DWG = “973E0415G002”;
e.fromObject(objlQphRequest);
} catch (BrokerException ex) {
System.out.println(“Error on create event\n”+ex);
return;
}
/ Fill in the number of replies to be requested /
/
try {
e.setIntegerField(“replies_requested”,num_requested);
} catch (BrokerException ex) {
System.out.println(“Error on setting replies requested\n”+ex);
return;
}
/
/ Register general callback /
try {
c.registerCallback(sample_callback,null);
} catch (BrokerException ex) {
System.out.println(“Error on registering callback\n”+ex);
return;
}
/ Publish request and get replies */
try {
events = c.publishRequestAndWait(e,300000);
} catch (BrokerException ex) {
System.out.println(“Error on publish\n” + ex);
ex.printStackTrace();
return;
}
try {
QueryPartLifeReplyDoc objlQphReply = new QueryPartLifeReplyDoc();
BrokerEvent e1 = new BrokerEvent(c,“wm::is::Canonical::QueryPartLife::QueryPartLifeReplyDoc”);
BrokerEvent e2 ;
// String test = null;
e1.toObject(objlQphReply);
System.out.println(“objlQphReply” + objlQphReply);
// objlQphReply =(QueryPartLifeReplyDoc) e1.getStorageObject();
// System.out.println(“objlQphReply” + objlQphReply);
e2 = e1.getEventSeqField(“Line”, 0, 1);
System.out.println("*****e2::" + e2);
} catch (Exception ex) {
System.out.println(“Error getting reply event\n” + ex);
ex.printStackTrace();
return;
}
/ Print results /
System.out.println(“Received “+events.length+” replies.”);
System.out.println(“after publish and wait” + events[0]);
for(int i=0; i<events.length; ++i) {
/ Test the event to determine what kind of reply it is /
if (events[i].isNullReply()) {
System.out.println(“Null reply received.”);
} else if (events[i].isErrorReply()) {
System.out.println(“Error reply received.”);
} else {
st= events[i].toString();
System.out.println(“Data reply #”+(i+1)+" received\n"+st);
}
}
try {
c.cancelCallbacks();
} catch (BrokerException ex) {
System.out.println(“Error on cancel callbacks\n”+ex);
return;
}
/ Clean up/
try {
c.destroy();
} catch (BrokerException ex) {
System.out.println(“Error on destroy client\n”+ex);
return;
}
}
}
Thanks,
Babu