on 03-14-2007 2:17 PM
For an adaptive WebService the model must be instantiated manually.
This is described for 1:1 relations between model nodes, but what's about 1:n?
The root node of a 1:n relation has a setIXXX(List list) method, so in wdDoInit() i can call it with root.setXXX(new ArrayList());
But how do I have to instantiate the childs?
TIA
Thomas Paulsen
Hi Thomas,
If you have any child nodes then you have to find the corresponding structure/table associated with your child node and then you have to instantiate the child nodes in the following way.
You can write the below code in the wdDoInit() of component controller.
public void wdDoInit()
{
//@@begin wdDoInit()
// Create a new element in the Bapi_Flight_Getlist_Input node
Bapi_Flight_Getlist_Input input = new Bapi_Flight_Getlist_Input();
wdContext.nodeBapi_Flight_Getlist_Input().bind(input);
// Create new elements in the Destination_From and Destination_To nodes
input.set<Destination_From>(new Bapisfldst());
input.set<Destination_To>(new Bapisfldst());
//Here <b>Bapisfldst </b>is a structure in R/3.
//If it a table then you need to use add instead of set.
ZTest_tab tab = new ZTest_tab();
input.add<MyTab>(tab );
//@@end
}
Regards,
Jhansi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Jhansi
Sorry, a little bit late, but vacation and easter and a hdd crash (aarrrgghh)....
I'd found the input.add<tab>.(new tabElement(model)) method, and it works fine for inputs, because I know the number of elements and I can use it in wdDoInit() or any other method during the preprocessing of the call.
But how to handle the output of a call if it returns a list of elements?
Regards,
Thomas
Hi Bertram
I know how to bind a table UI element to the context node, I don't know how to bind one to the model.
After binding a table UI element to the context node and processing the call the table is empty.
I think because I have no model nodes because I don't know where and how to create the model nodes
Regards
Thomas
Hi Thomas,
look at my newest in-depth tutorial and article on using the <b>Adaptive Web Service Model</b>
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/301ff0bb-74ca-2910-fa99-eae392695aad">Creating an E-Mail Client Using Web Dynpro's Adaptive Web Service Model</a>
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/900bbf94-a7a8-2910-e298-a651b4706c1e">WDJ Adaptive Web Service Model Controller Coding Explained</a>
I will roll out this new material very soon. You can allready access it.
Regards, Bertram
Hi Bertram,
I'd followed the 2nd tutorial step by step.
The "Variables" window of the debugger shows that calling the wdcontext.nodeResponse().invalidate() creates a node "Response" in the childs list of the request node.
But there are differences between the "Response" and the "SendMail" nodes
- the "parentElement" property is empty/null (!!!). In my opinion It should refer to the request element too.
- the "elements" property is empty (null)
- the "children" property is empty (null)
In my case the response should return a structure, so the "children" property should be non-empty.
The same request works fine when using non-adaptive WebService, so there must be something wrong when I'm using the adaptive WebService model.
Regards
Thomas
Message was edited by:
Thomas Paulsen
Hi Bertram
The structure:
request
- requestIn
- requestIn - Attrib1
- requestIn - Attrib2
- requestIn - Attrib3
- requestIn - Attrib4
- response
- response - Out
- response - Out - ListName
- response - Out - ListName - Elements [0...n]
- response - Out - ListName - Elements - Attrib1
- response - Out - ListName - Elements - Attrib2
Regards
Thomas
Hi Bertram,
the methods:
public void wdDoInit()
{
MyModel model = new MyModel();
TWdProcessIn tWdProcessIn = new TWdProcessIn(model);
WdRequest request = new WdRequest(model);
request.setWdProcessIn(tWdProcessIn);
wdContext.nodeRequest().bind(request);
}
public void executeRequest( )
{
IWDMessageManager manager = wdComponentAPI.getMessageManager();
try
{
wdContext.currentRequestElement().modelObject().execute();
wdContext.nodeResponse().invalidate();
} catch(Exception ce) {
manager.reportException(ce.getMessage(), false);
}
}
Regards
Thomas<i></i><i></i>
Exactly my point.
You need to create the elements and assign dummy values.
Let me give you a example.Lets says your model response class is called
ResponseABC.
, then in you init or wherever before webservice call ,
Request_MAINSERVICE rserv = new Request_MAINSERVICE(model);
COMPLEX_TYPE_TOPELEVELMODEL top = new COMPLEX_TYPE_TOPELEVELMODEL;
rserv.setXXX(top);
ResponseABC rabc = new ResponseABC();
top.getOriginalBean().setYYY(rabc);
wdContext.node<NameoftoplevelnodeinVIEW>.bind(rserv);
This way even though cardinality is zero , u create one element and thus u wont get the error.
This is the basic idea , hope you figure it out.
HOPE SAP understands that a lot of times we use external web services and hence really in no position to control the cardinality and thus do something to make it easier for us.Either that or let us know if there really is someother easier way.
Hi Vasuki,
you refer to the former Web Service Model (.getOriginalBean()). Do not mix up workarounds here among the different Web Service model flavors. Adding a dummy object instance to the model node Return is not needed. The Web Dynpro Runtime will automatically set a reference to the response object in the model object graph.
Regards, Bertram
Hi Thomas,
does the Web Service really return data? To find this out easily do the following steps:
1) Add a TextEdit UI Element to you View Layout and set Rows=20
2) Bind it to a context attribute RequestTrace of type string
3) After executing your adaptive Web Service object invoke
requestMO.execute();
wdContext.currentContextElement().setRequestTrace(requestMO.toString());
4) Start your application and have a look at the response of your Web Service. Does it really return data?
Regards, Bertram
Hi Bertram Ganz /Thomas ,
Sorry in that case then.I guessed the same way would work for instantiating in both cases.But i would imagine still that the idea remains the same.
Good luck Thomas
PS : Bertram Ganz : Maybe a bit out of topic , Would you have any idea from which release adaptive model will support external web services ? Thanks for any info.
Message was edited by:
vasuki lm
Hi Bertram
5 items in the list:
...
<target roleName="Response">
<modelObject class="Response_WdSearchWorkspace">
<target roleName="WdSearchWorkspace_Out">
<modelObject class="TWdSearchWorkspaceProcessOut">
<target roleName="Workspaces">
<modelObject class="Workspaces">
<targets roleName="Item">
<modelObject class="Item">
<attribute name="Name" value="name 1"/>
<attribute name="Id" value="68"/>
</modelObject>
<modelObject class="Item">
<attribute name="Name" value="name 2"/>
<attribute name="Id" value="67"/>
</modelObject>
<modelObject class="Item">
<attribute name="Name" value="name 3 "/>
<attribute name="Id" value="69"/>
</modelObject>
<modelObject class="Item">
<attribute name="Name" value="name 4"/>
<attribute name="Id" value="70"/>
</modelObject>
<modelObject class="Item">
<attribute name="Name" value="name 5"/>
<attribute name="Id" value="71"/>
</modelObject>
</targets>
</modelObject>
</target>
</modelObject>
</target></modelObject></target>
Hi Thomas,
Do you have addXXX(XXX xxx) method for your model?
Best regards, Maksim Rashchynski.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.