cancel
Showing results for 
Search instead for 
Did you mean: 

WebDynpro call WebService No Context Binding

Former Member
0 Kudos

Hello,

I have import a WebService in my WebDynpro Application. I have mapped the Context, but the binding doesn't work.

//@@begin wdDoInit()

wdContext.nodeStart().currentStartElement().setDatum("20060704");

wdContext.nodeStart().currentStartElement().setZeit("19:00");

wdContext.nodeProzessdaten().currentProzessdatenElement().setID("1234");

wdContext.nodeProzessstart().currentProzessstartElement().setDatum("20060704");

wdContext.nodeProzessstart().currentProzessstartElement().setZeit("19:00");

wdContext.nodeAktivitaet().currentAktivitaetElement().setID("2");

wdContext.nodeAktivitaet().currentAktivitaetElement().setStatus("in Arbeit");

//@@end

The structure of my Context is:

Node Request... 1.level

Node Processinstance... 2.level

Node processdata... 3.level

Attribute iD... for Node processdata

Node activity... 4.level

Attribute iD... for Node activity

Attribute status... for Node activity

Node start... 5.level

Attribute date... for Node start

Attribute time... for Node start

Node processstart... 4.level

Attribute date... for Node processstart

Attribute time... for Node processstart

I have a NullPointerException on the code line wit first 'setDatum'

Can anybody help me?

best regards

karsten

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi @all,

thank you for your answers.

@Gareth

It's been no changes. I have import a simple webservice for test and it works. But my extensive webservice does not work.

@Darren

I know the sample. This code is in my Controller. The webservice in this sample has a simple structure.

I will test the answer from Satyajit.

best regards

karsten

darren_hague
Contributor
0 Kudos

It looks like you may be missing a couple of lines to create the top-level context node. The tutorial at https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/creating... has the lines:


public void wdDoInit() {
 //@@begin wdDoInit()
 // create a new instance of the Web Service ModelClass
 Request_SendEmailPortType_sendEmail req = new Request_SendEmailPortType_sendEmail();
 // bind new instance of the Web Service ModelClass to the
 // independent Model Node 'WebServiceEmail'
 wdContext.nodeWebServiceEmail().bind(req);
 //@@end
}

Hope this helps,

Darren

Former Member
0 Kudos

Hi Pravesh, hiRajeev,

yes my cardinality is 0..1, but i can not change it. I can change the cardinality on the first level node, but then i have error message: com.sap.tc.webdynpro.progmodel.context.ContextException: Node(IdentComp.Request_MI_O_ProzessstartS_MI_O_ProzessstartS): cannot fill a ModelNode automatically. Change the cardinality or use a supply function.

I have checked the webservice and the cardinality is set min.1 and max.1 (1..1). After import webservice in my WD application i see cardinality 0..1.

best regards

karsten

Former Member
0 Kudos

Hi Karsten,

Don't try to access/modify your model nodes directly. Instead create value nodes with the exact same structure as your model nodes. Only the node and the subnode names should differ. But all attributes under these nodes should have the same names as in the model nodes. Change cardinality of this value node and fill up these value nodes. You can then use WDCopyService.copyCorresponding(valueNode,modelNode) to populate the model nodes before executing.

Regards,

Satyajit.

Former Member
0 Kudos

Or alternatively you could just create an element in your node and then populate the data into it.

The null pointer exception you are getting is probably because you are trying to put data into an element of a node that doesn't exist. As the cardinality is 0..n you start off with no elements in your node. Before you can put data into it you have to create an empty element.

Think of it like having a database table with no rows - before you can put data into a row you have to create the empty row.

Hope this helps,

Gareth.

Former Member
0 Kudos

Hi Karsten ,

I think you have to make Collection Cardinality 1..n OR 1..0 for each node above your start node.

Regards,

Rajeev

pravesh_verma
Active Contributor
0 Kudos

Hi Karsten,

I think the problem is due o the cardinality of the node "<b>Start</b>". In the context hierarchy, at level 5:

<b>Node</b> start... <b>5.level</b>

Attribute date... for Node start

Attribute time... for Node start

Change the cardinality of the node Start to 1:n, probably it would have been 0:n.

I hope this solves your problem. In case of any problem kindly revert back!!

Regards

Pravesh

PS: Please consider rewarding points if helpful and solved.