cancel
Showing results for 
Search instead for 
Did you mean: 

Web Dynpro and Web Service Error

Former Member
0 Kudos

Hi experts,

I followed the blog u201CDeveloping Web Services in J2EEu201D /people/lakshmi.prasad5/blog/2009/06/30/developing-web-services-in-j2ee-and-consuming-in-sap-netweaver-visual-composer-part1 and is very well explained and easy to follow. The author does two Methods and the final Web Service concatenates input fields. One Method concatenates two words and the second Method concatenates three words, the final result is the concatenation of the words in both cases. The Web Services is working fine I already tested and do it in a Visual Composer Project. Now, I want to Execute the Web Service in a Web Dynpro for Java WD4J Project. I did my application, my model (ConcatinationWSModel) and my View. I mapped the class that concatenates two words and is call u201CRequest_ConcatinationOfStringu201D. The problem comes with the Execution of the Web Service and is showing me the next exception:

u201Ccom.sap.tc.webdynpro.model.webservice.api.WDWSModelExecuteException: Exception on execution of web service with WSDL URL 'http://<host>:<port>/WebServiceconCat/Config1?wsdl ' with operation 'concatinationOfStrings' in interface 'WebServiceconCatVi_Document'u201D

My method DoInit (Set SAP & UK):

public void wdDoInit()
  {
    //@@begin wdDoInit()
		ConcatinationWSModel model = new ConcatinationWSModel();
		Request_ConcatinationOfStrings input = new Request_ConcatinationOfStrings(model);
		wdContext.nodeRequest_ConcatinationOfStrings().bind(input);
		ConcatinationOfStrings input2 = new ConcatinationOfStrings(model);
		wdContext.nodeConcatinationOfStrings().bind(input2);
		input2.setFString("SAP");
		input2.setSString("UK");
		ConcatinationOfStringsResponse input3 = new ConcatinationOfStringsResponse(model);
	
    //@@end

My method onAction is:

public void onActionExecuteWS(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionExecuteWS(ServerEvent)

	try {
		wdContext.currentRequest_ConcatinationOfStringsElement().modelObject().execute();
 wdContext.nodeRequest_ConcatinationOfStrings().invalidate();
	
	}
	
	catch (Exception ex)
				// TODO: handle exception
					{
				//	   If an exception is thrown, then the stack trace will be printed
		wdComponentAPI.getMessageManager().reportException("The error is: " + ex,true);
		}
	
    //@@end

I believe that the error is in the way I am executing the Web Service but I am not sure. Any help will be appreciated.

Best Regards

David Corté

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

What is the structure of your WS? I see you are binding input, input2 and input3 to the model, each one has diferent type, but my guess is that it should only be 1 input, though I might be wrong, if you could put the structure of your WS from the root node to the very last node of the WS I might be able to help you.

Regards,

JV

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Jesus,

Your answer was very helpful..... The problem was with my code. The way I was executing my web service was wrong..... There are two things we have to keep in mind while we invoke any web service.... The doinit method and the execution sentence.....

public void wdDoInit()
  {
    //@@begin wdDoInit()

	model = new ModelWebServcie();
		
	Request_ConcatinationOfStrings input = new Request_ConcatinationOfStrings(model);
	ConcatinationOfStrings input2 = new ConcatinationOfStrings(model);
	
	input.setConcatinationOfStrings(input2);
	
	wdContext.nodeRequest_ConcatinationOfStrings().bind(input);	
	
    //@@end

and the exection method:

public void ExecuteWebService( )
  {
    //@@begin ExecuteWebService()
	
	
	try {
				wdContext.currentRequest_ConcatinationOfStringsElement().modelObject().execute();
				wdContext.nodeResponse().invalidate();
		
		}
			
			catch (Exception ex)
					// TODO: handle exception
	
					{
					//	   If an exception is thrown, then the stack trace will be printed
			wdComponentAPI.getMessageManager().reportException("El error en ExecuteWS es: " + ex,true);
			wdComponentAPI.getMessageManager().reportSuccess("El Web Service fue ejecutado con exito");
			}

    //@@end

Declare member variable for model instance:

//@@begin others
  private ModelWebServcie model;
  //@@end

Thank you for everything...

Regards

David Corté