WCF Serialization List of objects
Below is a WCF REST service, which accepts TestEmp object. This TestEmp has a list of Jobs which I'm not able to deserialize. Below is a test application which I'm using for testing the deserialization
When I declare as public
List<TestJob> Jobs { get; set; } it works. How can I make it work with the way it is right now?
// Error
The value "System.Collections.Generic.Dictionary`2[System.String,System.Object]" is not of type "TestJob" and cannot be used in this generic collection. Parameter name: value
// Test Application Code
TestJob oj1 = new TestJob();
JOBID = "1";
JOBTITLE = "dev";
TestJob oj2 = new TestJob();
oj2.JOBID = "2";
oj2.JOBTITLE = "arch";
TestEmp oTestEmp = new TestEmp();
oTestEmp.Name = "test";
oTestEmp.Jobs = new TestJobs { oj1, oj2 };
string json = new JavaScriptSerializer().Serialize(oTestEmp);
TestEmp ap = new JavaScriptSerializer().Deserialize<TestEmp>(json); //Error
//Data Contract
[DataContract]
public class TestEmp
[DataMember]
public string Name { get; set; }
[DataMember]
public TestJobs Jobs { get; set; }
[DataContract]
public class TestJobs : List<TestJob>
[DataContract]
public class TestJob
[DataMember]
public string JOBID { get; set; }
[DataMember]
public string JOBTITLE { get; set; }
Hi,
For this scenario, it’s recommended that you use the following way to implement this:
[DataContract]
public class TestEmp
[DataMember]
public string Name { get; set; }
[DataMember]
public List<TestJob> Jobs { get; set; }
For more information, you could refer to:
http://forums.asp.net/t/1345001.aspx?How+to+Inherit+from+System+Collections+Generic+List+Of+T+
Regards
Similar Messages
-
Need help serialize a collection object
I have a class that's going to manage a list of paths stored as strings as "ArrayList<String> fileList = null;". I can't figure out how to serialize the fileList object. The class that contains the fileList implements Externalizable. here are the read and write functions:
public void readExternal(ObjectInput in) throws IOException
fileList = (ArrayList)in.readObject();
public void writeExternal(ObjectOutput out) throws IOException//, ClassNotFoundException
out.writeObject(fileList);
}I've tried lots of different things and nothing works. Anybody know how to serialize an ArrayList? Is ArrayList the best class for the job?I have a class that's going to manage a list of paths
stored as strings as "ArrayList<String> fileList =
null;". I can't figure out how to serialize the
fileList object. You don't have to do anything to serialize ArrayList, it is already Serializable.
The class that contains the fileList
implements Externalizable. here are the read and
write functions:I will assume there is a good reason this class (that contains the fileList) can itself not be Serializable and needs to be Externelizable.
>
public void readExternal(ObjectInput in) throws
s IOException
fileList = (ArrayList)in.readObject();
public void writeExternal(ObjectOutput out) throws
s IOException//, ClassNotFoundException
out.writeObject(fileList);
}I've tried lots of different things and nothing
works. Anybody know how to serialize an ArrayList? Is
ArrayList the best class for the job?I tried the same example -- with code to make it compilable and testable -- and it works as expected.
What exactly do you mean when you say "nothing works"? -
"Error consuming WCF service metadata.
Object reference not set to an instance of an object."
I have no clue what happen to my BizTalk. I checked all the below forum but m clueless why BTS not consuming WCF through Generated Items. I tried both metadata exhange endpoint and metadata file through
svcutil. but all my wcf services are working fine with .net C# client.
http://blogs.msdn.com/b/appfabriccat/archive/2010/11/23/how-using-duplex-mep-to-communicate-with-biztalk-from-a-net-application-or-a-wf-workflow-running-inside-appfabric-part-1.aspx
http://msdn.microsoft.com/en-us/library/bb226552.aspx
http://msdn.microsoft.com/en-us/library/bb798122.aspx
http://masteringbiztalkserver.wordpress.com/tag/wcf-service-consuming-wizard/
I reinstall the WCF lob Adapter SDK to my BizTalk VM but still no clue. no erros in event viewer nothing.
http://www.abdulazizfarooqi.wordpress.com Abdul Aziz Farooqi [BizTalk & SharePoint Consultant] MCPD Web & MCPD SharePoint 2010Thanks from me too Neal - this worked from me. I wan't able to consume directly from exchange because the certificate is broken. However, I was able to convince Google Chrome to let me view the /Services.wsdl and from there I could save the .wsdl and two
.xsd files. In my case the problem lay at the top of the .wsdl file. I changed the following:
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://schemas.microsoft.com/exchange/services/2006/messages" schemaLocation="messages.xsd"/>
</xs:schema>
by giving the same targetNamespace as assigned in the <wsdl:definitions element, so I ended up with
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.microsoft.com/exchange/services/2006/messages">
<xs:import namespace="http://schemas.microsoft.com/exchange/services/2006/messages" schemaLocation="messages.xsd"/>
</xs:schema> -
Need to find out the list of objects under a Transport
Hi ,
My requriement is to programatically find the list of objects under the Transport.
I tried using the table E071 but no luck is there any FM or table which gives me the list of objects assigned to the transport request
Regards,
kkTYPES: BEGIN OF ty_tasks,
trkorr TYPE trkorr,
trstatus TYPE trstatus,
strkorr TYPE strkorr,
as4user TYPE tr_as4user,
END OF ty_tasks,
BEGIN OF ty_object,
trkorr TYPE trkorr,
as4pos TYPE ddposition,
pgmid TYPE pgmid,
object TYPE trobjtype,
obj_name TYPE TROBJ_NAME,
lang TYPE spras,
END OF ty_object,
SELECT-OPTIONS : so_trans FOR e070-trkorr
*selection from table e070.
SELECT trkorr
trstatus
strkorr
as4user
FROM e070 INTO TABLE it_tasks
WHERE strkorr IN so_trans or
trkorr in so_trans.
IF SY-SUBRC = 0.
*selection from table e071 to get all the objects
*under the respective task/request.
data: g_trans type e070-trkorr,
g_strkorr type e070-strkorr.
SELECT trkorr
as4pos
pgmid
object
obj_name
lang FROM e071 INTO TABLE it_object
FOR ALL ENTRIES IN it_tasks
WHERE trkorr = it_tasks-strkorr.
hope it might be helpfull.
regards ,
aby -
Best Practice for caching global list of objects
Here's my situation, (I'm guessing this is mostly a question about cache synchronization):
I have a database with several tables that contain between 10-50 rows of information. The values in these tables CAN be added/edited/deleted, but this happens VERY RARELY. I have to retrieve a list of these objects VERY FREQUENTLY (sometimes all, sometimes with a simple filter) throughout the application.
What I would like to do is to load these up at startup time and then only query the cache from then on out, managing the cache manually when necessary.
My questions are:
What's the best way to guarantee that I can load a list of objects into the cache and always have them there?
In the above scenario, would I only need to synchronize the cache on add and delete? Would edits be handled automatically?
Is it better to ditch this approach and to just cache them myself (this doesn't sound great for deploying in a cluster)?
Ideas?The cache synch feature as it exists today is kind of an "all or nothing" thing. You either synch everything in your app, or nothing in your app. There isn't really any mechanism within TopLink cache synch you can exploit for more app specific cache synch.
Keeping in mind that I haven't spent much time looking at your app and use cases, I still think that the helper class is the way to go, because it sounds like your need for refreshing is rather infrequent and very specific. I would just make use of JMS and have your app send updates.
I.e., in some node in the cluster:
Vector changed = new Vector();
UnitOfWork uow= session.acquireUnitOfWork();
MyObject mo = uow.registerObject(someObject);
// user updates mo in a GUI
changed.addElement(mo);
uow.commit();
MoHelper.broadcastChange(changed);
Then in MoHelper:
public void broadcast(Vector changed) {
Hashtable classnameAndIds = new Hashtable();
iterate over changed
if (i.getClassname() exists in classAndIDs)
classAndIds.get(i.getClassname()).add(i.getId());
else {
Vector vc = new Vector();
vc.add(i.getId())
classAndIds.add(i.getClassname(),vc);
jmsTopic.send(classAndIds);
Then in each node in the cluster you have a listener to the topic/queue:
public void processJMSMessage(Hashtable classnameAndIds) {
iterate over classAndIds
Class c = Class.forname(classname);
ReadAllQuery raq = new ReadAllQuery(c);
raq.refreshIdentityMapResult();
ExpressionBuilder b = new ExpressionBuilder();
Expression exp = b.get("id").in(idsVector);
roq.setSelectionCriteria(exp);
session.executeQuery(roq);
- Don -
Dynamic List of Objects OracleAS Portals
<img class="emoticon" src="images/emoticons/confused.gif" border="0" alt="" />
Hello hope someone can help me
I have a <strong>List of Objects</strong>, the thing is that I want that list to give a <strong>parameter</strong>, so i can use it in a <strong>query</strong> for showing s<strong>pecific
content</strong>, from a <strong>database</strong>, depending on the <strong>selected item</strong>, but is that posible, or should I use like a combobox or what do
you recommend??
<p>
<strong>thanks in advance!! </strong><sup><strong> ^_^</strong>
</sup>
</p>
Edited by: DunkelBlume on Sep 2, 2008 11:54 AMHi,
a list used in the singleSelectOne component does not change or set the currency in the list VO (in opposite to the navigation list). So this synchronization needs to be done programmatically. Examples of dependent list of values are available here
--> example 62 http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html
--> word document you can download from http://thepeninsulasedge.com/frank_nimphius/2008/05/16/blogbuster-treasures-hunt-blog-entries-from-the-lost-orablogs-blog-for-download/
Frank -
Entity object attribute with a list of objects
Does anyone know how one sets up an entity object that has an attribute with a list of objects as the type? (assuming that's supported)
as in:
CREATE TYPE phones AS VARRAY(10) OF varchar2(10);
Create table suppliers (supcode number(5),
Company varchar2(20),
ph phones);
The SOA Suite in jDeveloper (new Entity Object/attributes etc) has an ARRAY that can point to REF or OBJECT. Neither work. When I try to Create DB Object later from the Entity Object I've created I get an invalid type.What you suggested about "validation codes on the VO" is not written on the ADF Documentation.
I try to blindly/strictly follow best practices (particularly on Validations, using Declartive and/or built in validators) on most ADF documentation and blogs but there are many scenarios on coding some large ADF projects that I think must veer away from the best practices stated on the documentation or maybe add new rules on the documentation depending on how complex an ADF project would be.
I religiously followed best practices stated on the documentation to use Entity and Attribute Validators when performing validations. What I did was i had created lots of Custom Validators (by implementing JboVAlidatorInterface interface) for each of the attributes on an Entity Object that need validated. So those validator is valid only for one attribute, its not reusable. And those validation codes either have reference to a ViewObject or call some PL/SQL procedure. So at some point are codes became messy.
Ultimately the whole project became harder to manage when the codes became large. Now I am trying to refactor the whole application by separating it into project/package and I am hoping to do it with little Re-coding as possible.
Hope to get your opinion on this one.
regards,
Anton -
What is Piece List, Work List and Object List
Hi All,
Can you please give idea about Piece List, Work List and Object List in BI.
What are their uses?Hi,
Piece lists
You can use this request type to set up your own object lists and save them under a name of your choice.
For more info on this go through the link below
http://help.sap.com/saphelp_sm32/helpdata/EN/57/38e1b64eb711d182bf0000e829fbfe/content.htm
Worklists
Worklists are the quickest and most convenient way of accessing the objects that you need to translate. Translators can call up a worklist in SE63 once a system has been completely set up for translation.
For more info on this go through the link below
http://help.sap.com/saphelp_sm310/helpdata/en/77/571a1f492011d1894a0000e829fbbd/content.htm
Object Lists
The Object Lists tab page in transaction SLWB enables you to create and manage object lists in the Translation Planner.
An object list should contain all objects relevant for translation. You can create object lists according to a variety of criteria
For more info on this go through the link below
http://help.sap.com/saphelp_sm32/helpdata/EN/d4/341964249711d3b29e0000e817ab98/content.htm
Regards,
Marasa. -
Hi All,
I have list of object. each object has some fields. ex. item, type, zone. I want to retrieve it in jsp. Now i am using
<%List itemList = (List)session.getAttribute(Constants.ITEM); %>
<% for(int i =0;i<itemList.size();i++){
NhopItemDef nhopItemDef= (NhopItemDef)itemList.get(i);
if(nhopItemDef!=null){
if(nhopItemDef.getItemType().trim().equals(Constants.BED_ZONE)){
%>
<tr >
<td class="tb_dred_left_bf" height="30">
<html:hidden property="item" value="<%=nhopItemDef.getItem()%>"/>
<%=nhopItemDef.getItem()%>
</td>
Please let me know how to implement it using logic:iterate or c:foreach. which is the best way to implement?
please provide some example codes here.
Thanks & regards
arullakshmiarullakshmi wrote:
Hi All,
I have list of object. each object has some fields. ex. item, type, zone. I want to retrieve it in jsp. Example:<c:forEach var="item" items="${itemList}">
<tr>
<td>${item.name}</td>
<td>${item.type}</td>
<td>${item.zone}</td>
</tr>
</c:forEach>For more information, check out a good [JSTL tutorial|http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL.html].
~ -
Best method for scrollable list of objects
I was attempting to create a list of objects in a scrollable pane with the ScrollPane object. I am having a very hard time customizing what is actually scrolling in that pane, though. By using a custom renderer class, I am able to change what it looks like and even add objects to it, but I am having trouble passing data to those objects at creation because it is loaded through the pane object itself.
What I would like to do is create an object with buttons on it (relative to that object) and be able to add multiple ones to a scrollable pane. I tried to figure out a way to be able to simply add my object as the item, but it seems to require a specific object. Is there any work around to this? What would be the best way of going about this?
Thanks for any help.Class: java.sql.DatabaseMetadata
Method: getSQLKeywords
Desc: Returns a comma-delimited list of all non-SQL92 keywords used by the database
Example (Source http://javaalmanac.com/egs/java.sql/GetSqlKeywords.html?l=rel ):
import java.sql.Connection;
import java.sql.DatabaseMetaData;
public String[] getSQLKeywords(Connection connection) {
String[] keywords = null;
try {
DatabaseMetaData dbmd = connection.getMetaData();
keywords = dbmd.getSQLKeywords().split(",\\s*");
} catch (SQLException e) {
// Handle Exception
return keywords;
SQL92 Keywords
The SQL92 specification is available for purchase. However, if you just want the full list of reserved words / keywords for a particular type of database, there is usually documentation provided by the database vendor.
Full Keyword List Oracle 8.0:
http://www-rohan.sdsu.edu/doc/oracle/server803/A54656_01/vol2_wor.htm#421705
For Other Oracle Versions:
- Visit technet.oracle.com
- Register for free
- Go to Documentation
- Look under K for Keywords in index for newer versions of Oracle
- Look under Programmer's Guide to the Oracle Call Interface for older versions of Oracle -
Tag files, Lists, and object typing
I'm passing a list of objects to a custom tag, created via a tag file.
I can access object properties in the jsp page like this -
<c:out value="${listOfItems[0].property}" />
but inside the tag it doesn't work. It understands that its being passed a list and the number of items in the list but not the type of objects in the list. I think I need to declare the type of object that the list is returning but I'm unsure of th jstl way of doing this.
advice?
thanksJSTL uses introspection/reflection to call methods/access properties.
It doesn't have to know the type of object in the list.
How are you accessing this object in your tag file? Using EL again? That should work fine. If you use java/scriptlet code then you will need to cast the object.
Have you declared the attribute that is being passed in? What type are you expecting? Default is String unless you specify otherwise. -
Serialization error for object (IDOC error 51)
hello,
Can Somebody help me with this??? this is what it gives me when the IDOC comes to the receiver instance (SAP R/3). The error code is 51.
Serialization error for object 01,S,12000677 . Expected counter 000001 < 000044 in IDoc
Message no. 5-300
Diagnosis
A serialization error has occurred for the HR object 01,S,12000677 that was received from the logical system E3B.
The expected serialization counter has the value 000001. However, the serialization counter in the IDoc has the value 000044 and is therefore too big. There are therefore older IDocs with this HR object with the serialization counter values in between. These IDocs have either not yet been posted, or have been posted incorrectly.
Procedure
Post all IDocs that have not yet been posted or that were posted incorrectly.
Thank you very much
PMHi David,
Please take a look at these threads..
Status code 51
IDOC Status 51
IDoc cannot be opened Error 51 (Inbound)
InfoPackage loading giving IDOC Error: Status 51
cheers,
Prashanth -
Is possible to make Serializable a Connection object?
Hi I would like to know if is possible to make Serializable a Connection Object, I would like to save the Connection object into a text file so other class can read it and execute a proper query. If is possible how can I do it?.
Thanks.Actually, if a class isn't already Serializable, you can't make it become Serializable reliably. Consider the following case:
class A
int x = 0;
public void setX(int new_x) { x = new_x; }
public int getX() { return x; }
class B extends A implements Serializable
int y = 0;
public void setY(int new_y) { y = new_y; }
public int getY() { return y; }
public static void main(String arg[]) throws Exception
B b = new B();
b.setX(10);
b.setY(12);
someObjectOutputStream.writeObject(b);
}The problem with this is that the implementation of Serializable by class B does not affect class A. In the above example, the ObjectInputStream that obtains the instance of B will have a y value of 12, but an x value of 0 (not 10).
Thus, unless the Connection object implemented Serializable to begin with, it can't become Serializable. And, as the above post has described, the implementers of the Connection object would not make it Serializable as the local Connection object uses underlying O/S resources which cannot simply be transformed into a byte array. -
Changing focus line in List View object?
Hi -
I have an list view object on my dashboard that displays about 50 lines of data, with the very first line being a total line. You can drill-into the any one item on the list view to see detail in another chart. The content of the list view is updated when the date range is change from current month to previous month.
My question is this: if I select the 5th line item in the list view then change the date range, the list view retains the focus on the 5th line even after it is updated - so is it possible to force the list view to change the focus to the 1st line everytime the date range changes?
I am guessing no because I see nothing in the properties of the list view that allows you to control focus.
Thanks in Advance!Melissa,
No there is no option as such in the component. May be you can use the Reset button component.
-Anil -
Function Module which gives complete list of objects that another object to
Hi All,
Is there any standard FM that can give us complete list of objects that another object(Order/Cost Center) settles to??
Thanks in advance,
PrathimaHi,
Question is not clear.
Revert back,
Regards,
Naveen
Maybe you are looking for
-
How to upgrade (with clean install) a OEL4 server to OL5 on a live system
My problem is that I cannot find any meaningful information on how to perform a OL upgrade on a live system with a running database. The system is running OEL 4.9 (migrated from RHEL 4 to OEL) and I want to upgrade it to OL 5.7 (wanted to use 6.1 but
-
MBA Black Screen - and ALWAYS is black (will not boot into OS)
I've read and done everything. Many are saying they are able to get a restart and change settings - but I can not get pas the black screen at all. I continue to do a hard restart, it goes to black screen. I use the control-option-shift-power, and it
-
My itunes was being updated then it stopped and showed an error message
I download the newest version of Itunes on my PC windows 7 and then half way it stops and shows a message that says something about me to "manualy update the itunes" The only reawl resason i wanted to download a new version was to download the new so
-
How do you remove apps/programmes from the dock on my Mac?
How do you remove apps/programmes from the dock on my Mac? Everytime I download something like pages, key note and twitter it appears on the dock at the bottom of the screen, How do I remove things from this dock? Thanks
-
Apple TV not authorized to view content -- solution remove family videos??
Hi. Whenever I add add family videos (mp4, created with CRUNCH), my movie rentals stop working on Apple TV. I get the message saying that Apple TV is not authorized to view content. These are movies that I have paid for and have been downloaded direc