Skip to Content
avatar image
Former Member

inserting and displaying records to db table using web service

Hi all,

i hv created a web service that has two methods :

public supportClass InsertRec(string, string, date)

and

public supportClass ViewRec()

I m using the WSDL to ctreate a Model and mapped The Request Nodes to the controller and then to the view...

In the context of the controlleri have created a new NOde TESTINGNODE with the value attributes of type String ,String and Date.

my view has a form from which i shud be able to insert records into the table on click of INSERT and retrieve the records on click of SHOW.

so i have bound the input fields to the attr of tresting node , as the attr that i get from web service model are of Calendar type..

And created a table by binding it to the TESTINGNODE.

now to insert and retrieve records i have set the values that i get from my form to the input parameters of REQUEST_MY_WS_insertRecords..

Similarly i have retieve the records of Result_VIEW and set that to testing node..

MY PROBLEM IS I AM NOT ABLE TO INSERT AND RETRIEVE RECORDS

i have written the follwing code..

  public void ExecuteInsert( )
  {
    //@@begin ExecuteInsert()
    
	Request_CHECH_DATE_WSViDocument_insertRecords obj = null;
	//Response_CHECH_DATE_WSViDocument_insertRecords objResp = null;
	
    IPublicDATE_CUST.ITestingNodeNode node = wdContext.nodeTestingNode();
    IPublicDATE_CUST.ITestingNodeElement elem = null;
	
    
	//wdComponentAPI.getMessageManager().reportWarning(String.valueOf(node.size()));
    
   try {
		 
				 obj = new Request_CHECH_DATE_WSViDocument_insertRecords();
		    	elem= node.currentTestingNodeElement();
		    	
				Date start = elem.getStartDate();
				Date end = elem.getEndDate();
				
				Calendar startthis = Calendar.getInstance();
				Calendar endthis = Calendar.getInstance();
			
				SimpleDateFormat inputFormat = new SimpleDateFormat("yyyyMMddHHmmss");
				SimpleDateFormat timeFormatStored = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			
				String temp = start.toString();
				String temp2 = start.toString();
			
				
					startthis.setTime(inputFormat.parse(temp));
					endthis.setTime(inputFormat.parse(temp2));
					
				 obj.setTitle(elem.getTitle());
				 obj.setStatus(elem.getStatus());
				 obj.setStDt(startthis);
				 obj.setEndDt(endthis);
				
			wdContext.currentRequest_CHECH_DATE_WSViDocument_insertRecordsElement().modelObject().execute();    	
		 
	} catch (Exception e) {
		// TODO Auto-generated catch block
		wdComponentAPI.getMessageManager().reportWarning("ERROR : " + e.getLocalizedMessage());
	}
	
	//wdComponentAPI.getMessageManager().reportWarning(obj.getTitle());
    
    wdContext.nodeTestingNode().invalidate();
    
    //@@end
  }

  //@@begin javadoc:ExecuteView()
  /** Declared method. */
  //@@end
  public void ExecuteView( )
  {
    //@@begin ExecuteView()
    
    try {
		
		
		Request_CHECH_DATE_WSViDocument_viewRecords obj = new Request_CHECH_DATE_WSViDocument_viewRecords();
		
		HelperClass[] help = obj.getResponse().getResultAsArray();
		List arr = obj.getResponse().getResult();
		
		for(int i = 0;i<=arr.size();i++)
		{
			IPublicDATE_CUST.ITestingNodeElement elem = wdContext.createTestingNodeElement();
			
			Calendar st = Calendar.getInstance();
			st = help<i>.getStDate();
			java.util.Date dt = st.getTime();
			long theTime = dt.getTime();
			Date start = new Date(theTime);
			
			Calendar endC = Calendar.getInstance();
			st = help<i>.getEndDate();
			java.util.Date dt1 = endC.getTime();
			long theTime1 = dt1.getTime();
			Date end = new Date(theTime1);
			
			elem.setTitle(help<i>.getTitle());
			elem.setStatus(help<i>.getStatus());
			elem.setStartDate(start);
			elem.setEndDate(end);
			
		}
		
		wdContext.currentRequest_CHECH_DATE_WSViDocument_viewRecordsElement().modelObject().execute();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
    
    //@@end
  }

PLZ help me to solve this problem ..

THANKS AND REGARDS,

Ankita

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Sep 01, 2008 at 10:56 AM

    Hi,

    Did you try intantiating the node for the Webservice model, add the values you want to insert in the elements of the webservice node and then try executing the model.

    Regards,

    Vivek.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Vivek,

      Im sorry i cudnt get u..

      i have created functionalities in session bean which has queries for inserting and retrieving records..

      i have bound the request nodes of web service model to the context.

      Ankita

  • avatar image
    Former Member
    Sep 01, 2008 at 11:40 AM

    Hi Ankita,

    Below are Modifications for ExecuteInsert() Method

    -


    1.)

    String targetAddr = <Target Address>; ( You can get Target Address from You Application --> Web Dynpro --> Models --> Model

    Name --> Logical Ports --> Config1Port_Document --> Double Click on it )

    wdContext.currentRequest_CHECH_DATE_WSViDocument_insertRecordsElement().modelObject()._setEndPoint(targetAddr);

    write the above code before the following line in your code

    wdContext.currentRequest_CHECH_DATE_WSViDocument_insertRecordsElement().modelObject().execute();

    2.)

    wdContext.currentRequest_CHECH_DATE_WSViDocument_insertRecordsElement().modelObject()._setEndPoint(targetAddr);

    write the below code Just after the above Line..

    wdContext.nodeResponse<Complete Response Node Name>().invalidate();

    Below are Modifications for ExecuteView() Method

    -


    1.)

    wdContext.<Your Request Node Name>().bind(new Request_CHECH_DATE_WSViDocument_viewRecords());

    write the above line instead of below Line.

    Request_CHECH_DATE_WSViDocument_viewRecords obj = new Request_CHECH_DATE_WSViDocument_viewRecords();

    2.)

    write the following Line after this Line :- elem.setEndDate(end);

    wdContext.nodeTestingNode().addElement(elem); // ( As last line in the for loop)

    3.) Write the following two lines before for loop

    wdContext.currentRequest_CHECH_DATE_WSViDocument_viewRecordsElement().modelObject().execute();

    wdContext.<NodeResponse>().invalidate();

    I think it will solve your Problem.

    If you have any more doubts feel free to ask me.

    With Regards,

    Roop Kumar.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Ankita,

      1.)write the following line of code as first line in the Insert Data Method.

      wdContext.nodeRequest_CHECH_DATE_WSViDocument_insertRecords.bind(new Request_CHECH_DATE_WSViDocument_insertRecords());

      2.)Delete the following Two Lines of Code from Your Code's Insert Method.

      Request_CHECH_DATE_WSViDocument_insertRecords obj = null;

      obj = new Request_CHECH_DATE_WSViDocument_insertRecords();

      If you have any more doubts feel free to ask me.

      With Regards,

      Roop Kumar.

  • avatar image
    Former Member
    Sep 01, 2008 at 12:12 PM

    Hi

    You didn't bind the webservice node.

    Insert the code after webservices instantiation(obj=new.....)

    wdcontext.nodeRequest_CHECH_DATE_WSViDocument_insertRecords.bind(obj);

    Regards

    Saba

    Add comment
    10|10000 characters needed characters exceeded