cancel
Showing results for 
Search instead for 
Did you mean: 

How to set Web Service parameters

Former Member
0 Kudos

Hi,

I imported exsiting web services in Web DynPro. I was able to make one of them work: one that takes no parameters and return a simple string.

I wanted to use another one that returns an array of Sensor ojects and takes 4 String arrays as parameters. I was unable to do it.

I thought let's first settle for something easier and I am now trying to call a web service (getUnitsForId) that takes a string as a parameter and return an array of Sensor Objects. I tried about everything that I could think of to set the parameter, but I am still getting a NullPointerException when I do setId("R2") (the string parameters). I get the same error no matter if I set it on the mapped model node of the controller or directly on the model object.

Here is my code in the wdDoInit of my controller. Any help would be greatly appreciated.

Thanks in advance!

Mathieu Poitras

    AnalsysisServices model = new AnalsysisServices();
    wdContext.nodeRequest_GetUnitsForId().bind(new Request_GetUnitsForId(model));
	GetUnitsForId wReq = new GetUnitsForId(model);
	wReq.setId("R2");
	wdContext.nodeRequest_GetUnitsForId().nodeGetUnitsForId().bind(wReq);
	wdContext.currentGetUnitsForIdElement().modelObject().getId();
    
    try
    {
		wdContext.currentRequest_GetUnitsForIdElement().modelObject().execute();
		
    }
    catch(Exception pE)
    {
    	pE.printStackTrace();
    }
	wdContext.nodeGetUnitsForIdResponse().invalidate();

The trace for the error I get is:


java.lang.NullPointerException
	at com.sap.tc.webdynpro.model.webservice.base.model.BaseGenericModelClass.setAttributeValue(BaseGenericModelClass.java:267)
	at com.sap.tc.webdynpro.model.webservice.gci.WSTypedModelClass.setAttributeValue(WSTypedModelClass.java:62)
	at com.sap.dc.avl.analysis.data.GetUnitsForId.setId(GetUnitsForId.java:52)
	at com.sap.dc.avl.pafd.PAFDAnalysis.wdDoInit(PAFDAnalysis.java:111)
	at com.sap.dc.avl.pafd.wdp.InternalPAFDAnalysis.wdDoInit(InternalPAFDAnalysis.java:284)
	at com.sap.tc.webdynpro.progmodel.generation.DelegatingComponent.doInit(DelegatingComponent.java:108)
	at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)
	at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)
	at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.init(ClientComponent.java:429)
	at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:362)
	at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.initApplication(ApplicationSession.java:700)
	at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:269)
	at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:711)
	at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:665)
	at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:232)
	at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:152)
	at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
	at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:46)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
	at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
	at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
	at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
	at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
	at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
	at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
	at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)


Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

I have replied to the similar issue in .

You can go through the following document also

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b2bc0932-0d01-0010-6d8e-cff...

Regards, Anilkumar

Former Member
0 Kudos

It actually worked for string parameters! I will try it later for arrays of objects and award you full points if it works.

So, the conclusion is:

You need to set the model objects between themselves then bind the request model object to the request node.

Thank you very much!

Former Member
0 Kudos

Hi ,

Please verify the webservice parameters once again.

Goto the webservice Navigator and test the webservice first and then test he webdynpro application.

Or

Second option is Try setting the proxy in your bean .

Ex: System.getProperties().put("http.proxyHost", "proxy");

System.getProperties().put("http.proxyPort", "8080");

Regards, Anilkumar

Former Member
0 Kudos

Hi,

I still haven't been able to use make it work (I am 100% sure that the web services is working, just not for web dynpro). Thus I am using the deprecated web services import from web dynpro and when I need to pass arrays I encode them as basic types array (String, int, long, etc ...).

Now the nicest solution but I lost 4 days on this issue and I cannot afford to lose more time.

Regards

Former Member
0 Kudos

Hi.

I have a similar problem:

In a SessionBean i have exported a function

public String returnTestString(String arg1);

through a webservice, which i have imported in a webdynrpo using a adaptive webservice model.

My code


			String hallo = "HelloWelt";
			wdThis.wdGetContext().currentContextElement().setDebugCaption(hallo);
			
			String_arctest model = new String_arctest();
			wdContext.nodeRequest_ReturnTestString().bind(new Request_ReturnTestString(model));
			
			wdContext.
				nodeRequest_ReturnTestString()
				.nodeReturnTestString()
				.bind(new ReturnTestString(model));
			
			wdContext.nodeRequest_ReturnTestString()
			                .nodeReturnTestString()
			                .currentReturnTestStringElement().setArg1("HalloWelt");		
			
			
			wdContext.nodeRequest_ReturnTestString()
				.currentRequest_ReturnTestStringElement().modelObject().execute();

throws a <i>com.sap.tc.webdynpro.model.webservice.api.WDWSModelExecuteException</i>

with this message cause

Cannot find the required parameter [arg1] in request message content

It would be great, if anyone can explain, what i am doing wrong. Thanks in advance.

Former Member
0 Kudos

Hi Mathieu,

I'm currently running into a similar issue. I'm trying to pass an array of Custom Objects into my webservice but I can't seem to get it to work.

However, I was able to pass a simple string to the webservice.

Say your structure is like this:

Request_GetUnitsForId

---Id (String)

---Response

|---Result

Here is how I usually do it:

wdContext.nodeRequest_GetUnitsForId().currentRequest_GetUnitsForId().setId("someId");

Does anyone know to pass an array of custom objects?

Former Member
0 Kudos

Hi Alaa,

We must not be the only ones with this issue. Even simple string arrays seems to be a complication for me.

I am using Netweaver 2004s and the old web services import is deprecated. So I used the Adaptive web services.

In the model created with the adaptive web services the parameters are not directly under the request node. I believe that the way you call the web services is using the deprecated model import for web services. I hope you won't have trouble if you upgrade.

The generated model now looks more like:


Request_GetUnitsForId
|---GetUnitsForId
    |---Id (String)
|---Response
    |---GetUnitsForId
        |---Response
            |---ArrayOfSensor
                |---Sensor
                    |---DataType
                    |---ObjectID
                    |---ObjectType
                    |---SensorID

The way I tried it:

These steps are necessary to actually create the elements and bind them to the model:


AnalsysisServices model = new AnalsysisServices();
wdContext.nodeRequest_GetUnitsForId().bind(new Request_GetUnitsForId(model));
wdContext.nodeRequest_GetUnitsForId().nodeGetUnitsForId().bind(new GetUnitsForId(model));

This is how I tried to set the parameters and where it is crashing with a NullPointerException.


wdContext.currentGetUnitsForIdElement().setId("R2");

If I find the way to pass arrays or to use the parameters with the new adaptive web services, I will make sure to post it here. I would appreciate if you would do the same.

Thanks!

Former Member
0 Kudos

I see. So there are changes in how we handle the webservice model between 2004 and 2004s.

Ok now instead of setting the id like this:

wdContext.currentGetUnitsForIdElement().setId("R2");

Try this in the component controller:

wdContext.nodeGetUnitsForId().currentGetUnitsForIdElement().setId("R2");

and see if this is gonna work. Because now there is no element under the main context node. If one exists it will exist under its corresponding node, i.e. nodeGetUnitForId.

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi,

Try like this

IRequest_GetUnitsForId requestElement = wdContext.currentRequest_GetUnitsForId();

requestElement.currentGetUnitsForId.setId(ID);

private IPublic<Iview> viewController=viewController.executeRequest_GetUnitsForId();

Response_GetUnitsForId responseElement = wdContext.currentResponse_GetUnitsForId();

Data = responseElement.modelObject().getResultAsArray();

Regards, Suresh KB

Former Member
0 Kudos

I have fixed part of the problem. Now I can set the parameter without getting an error:

The first part of the code stays the same:


AnalysisModel model = new AnalysisModel();
wdContext.nodeRequest_GetUnitsForId().bind(new Request_GetUnitsForId(model));
wdContext.nodeRequest_GetUnitsForId().nodeGetUnitsForId().bind(new GetUnitsForId(model));

Before:

wdContext.nodeGetUnitsForId().currentGetUnitsForIdElement().setId("R2");

Now:

wdContext.nodeGetUnitsForId().currentGetUnitsForIdElement().setId(new String("R2"));
(Added the new String())

Now it is crashing with an Exception on the execute:


wdContext.currentRequest_GetUnitsForIdElement().modelObject().execute();

(When debugging I see that the crash is coming from the execute() method for which I don't have the source code)

The stack trace:


SAPEngine_Application_Thread[impl:3]_0##0#0#Error##Plain###com.sap.tc.webdynpro.model.webservice.api.WDWSModelExecuteException: Exception on execution of web service with WSDL URL 'http://localhost:53000/analysis/all?wsdl' with operation 'getUnitsForId' in interface '{urn:analysisWsd/analysisVi/document}analysisVi_Document'
	at com.sap.tc.webdynpro.model.webservice.model.WSGenericModelClassExecutable.execute(WSGenericModelClassExecutable.java:64)
	at com.sap.tc.webdynpro.model.webservice.gci.WSTypedModelClassExecutable.execute(WSTypedModelClassExecutable.java:46)
	at com.sap.dc.avl.pafd.PAFDAnalysis.executeRequest_GetUnitsForId(PAFDAnalysis.java:278)
	at com.sap.dc.avl.pafd.wdp.InternalPAFDAnalysis.executeRequest_GetUnitsForId(InternalPAFDAnalysis.java:266)
	at com.sap.dc.avl.pafd.PAFDAnalysis.wdDoInit(PAFDAnalysis.java:112)
	at com.sap.dc.avl.pafd.wdp.InternalPAFDAnalysis.wdDoInit(InternalPAFDAnalysis.java:219)
	at com.sap.tc.webdynpro.progmodel.generation.DelegatingComponent.doInit(DelegatingComponent.java:108)
	at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)
	at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)
	at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.init(ClientComponent.java:429)
	at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:362)
	at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.initApplication(ApplicationSession.java:700)
	at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:269)
	at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:711)
	at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:665)
	at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:232)
	at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:152)
	at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
	at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:46)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
	at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
	at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
	at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
	at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
	at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
	at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
	at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
Caused by: java.lang.reflect.InvocationTargetException: Cannot find the required parameter [Id] in request message content.
	at com.sap.engine.services.webservices.jaxrpc.wsdl2java.soapbinding.MimeHttpBinding.processDocumentFault(MimeHttpBinding.java:922)
	at com.sap.engine.services.webservices.jaxrpc.wsdl2java.soapbinding.MimeHttpBinding.call(MimeHttpBinding.java:1432)
	at AllBindingStub._invoke(AllBindingStub.java:667)
	at com.sap.engine.services.webservices.espbase.client.dynamic.impl.DInterfaceInvokerImpl.invokeOperation(DInterfaceInvokerImpl.java:63)
	at com.sap.tc.webdynpro.model.webservice.model.WSGenericModelClassExecutable.execute(WSGenericModelClassExecutable.java:62)
	... 34 more
Caused by: javax.xml.rpc.soap.SOAPFaultException: Cannot find the required parameter [Id] in request message content.
	at com.sap.engine.services.webservices.jaxrpc.wsdl2java.soapbinding.MimeHttpBinding.buildFaultException(MimeHttpBinding.java:735)
	at com.sap.engine.services.webservices.jaxrpc.wsdl2java.soapbinding.MimeHttpBinding.processDocumentFault(MimeHttpBinding.java:857)
	... 38 more