Please help me..I wanna serialize/deserialize an object on WP7 on visual studio 2010 with c#. Why I can not use soapformatter? How can I do soap serialization/deserialization on wp7?
Is there a reason you need to use the Soap serializer?
If not (if you just need to do serialization to file for example), you can just use the XmlSerializer (which is very close to the Soap one iirc) and the DataContract one. My recommendation is to use the DataContract one with an empty namespace.
XmlSerializer:
http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer(v=vs.95).aspx
DataContract:
http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer(v=vs.95).aspx
Related
Is this a valid web service link since I tried ti import it several times to visual studio 2010 and 2012 and couldnt read it from code behind.
http://www.hotelston.com/ws/HotelService?wsdl
whats the service name I should call ?
Yes this is a valid WSDL and it is a WSI compliant WSDL as well. I ran the tests with SOAP UI and it appears to be fine. The service name is HotelService it has three ports one for SOAP 1.1 another for SOAP 1.2 and finally one for HTTP. It is document literal wrapped so cant see anything problematic.
I also imported the WSDL into a XML editor and had a look. It appears fine see image below.
I have a Web Service like ServiceA.asmx. What is the right way to consume it?
I have two ways to consume a service:
1)adding Service Refernce:
I have added Service Refernce of ServiceA.asmx ( Like in http://microsoftfeed.com/2011/part-14-how-to-consume-a-web-service-in-windows-phone-7) and i am able to call the Functions in Service like in the link i have given. If we use this way there is no need to parse the Result, Result returned in Objects(easy to use).
2)Hitting the URL and Calling asynchronously:
Here we can hit the URL, that function will call the asynchronous function that asynchronous function will return the response. But here response will be in XML here we have to parse that XML in to an Object.(not easy if any Big XML is there)
Please Guide me on this
Personally I would use the 'Add service reference' option. It's easy to use, and this option is added to Visual Studio especially for consuming web services. You can still use MVVM to build up your models/viewmodels.
I don't have the option to check it right now, but from my head the classes generated when adding the service reference also implement INotifyPropertyChanged. So you could probably use the object directly (if they are in the structure as you want to use it.) as your Model. Based on that model you can create your own ViewModel which you can bind to the UI.
To see how this works have a look at the code samples on MSDN:
Implementing the Model-View-ViewModel Pattern in a Windows Phone Application
Weather Forecast Sample
How can I go about saving an object of type GameSettings to IsolatedStorage on a Windows Phone 7 application made with XNA 4.0?
From what I can tell, you can't flag a class as serializable and ByteFormatter isn't available. I haven't come across a good way to convert an object to a byte array and write the array to the storage. And going beyond that, I have no idea how to go about converting said byte array back into an object.
Any help would be greatly appreciated!
There is no built in binary formatter on the platform but it does support XML and JSON serialization using the DataContractSerializer and DataContractJsonSerializer classes.
You can configure what is serialized via the DataContract and DataMember attributes.
I have an old VB 6 Application. I now want to access a Web service/web method in it, I am using MSSOAPLib30 DLL for the interaction.
Everything is fine with the simple types like int string.
But I am unable to send Complex types like Class and Structs.
Anybody have any suggestions?
You need to create a Type Mapper.
Microsoft SOAP Toolkit Type Mappers
If you have the opportunity, you can make things much easier by creating the code to call the web service in VB.NET and then using interop to invoke it from VB 6.0.
Calling Web Services from Visual Basic 6, the Easy Way
For strongly-typed & type-safe solution, I have to do the following step.
Create some Silverlight application.
Binding input control to Linq data class.
Validate data by using rule from attribute of data class.
Send data to server via WCF.
But, I have some question.
How to bind input control with linq data class property?
How to do that with minimal tiers(layers) and minimal required dll(for Silverlight project)?
PS. .Net RIA Service - May Preview isn't my final answer. Because size of all required dll and some generated code.
Thanks,
Well, I'm glad you know that .NET RIA Services will provide all of those things but I understand size is a consideration. Keep in mind though, since it looks like you're considering Silverlight 3 you can use the option to cache the framework assemblies to greatly reduce your Xap size:
http://www.wintellect.com/CS/blogs/jprosise/archive/2009/04/06/silverlight-3-s-new-assembly-caching.aspx
I'm not positive that caching applies to the RIA Services assemblies, but if so it would mean they're downloaded only once.
Assuming that's not what you want there are 2 other options to get data from the Linq classes (I'll assume you mean Entity Framework classes) to the client. The most simple method would be to create your own WCF Service as you've mentioned. That way you write data classes on the server and proxy classes automatically get generated on the client that mimic the server classes. The drawback here is business rules won't be shared between the two. So your data validation attributes will need to be written and enforced on the client & the server separately.
The next option is to use ADO.NET Data Services to move the data from the server to the client. This is a step above the previous option in that you won't have to write a WCF service yourself to host the data; it's generated for you. Of course it requires an extra Dll to be packaged in the Xap.
To answer some of your questions directly:
You can't ever bind an input control directly to a Linq data class. You can only bind controls to the client side proxy classes that are generated by referencing a WCF service (either one you wrote yourself or one provided by ADO.NET Data Services).
If you don't use .NET RIA Services you'll need to create a custom attribute to link to your business rules, then handle events on the data bindings manually to read the attribute and enforce your rules.
Use either of the above options to send data to the server - either your own custom WCF Service or ADO.NET Data Services.
Your final question about binding an input control to a property looks like this:
MyControl.xaml.cs:
public MyControl() {
this.DataContext = new LinqDataClass();
}
MyControl.xaml:
<TextBlock Text={Binding PropertyOnLinqDataClass}/>
Here, LinqDataClass is the client side representation of your server side Linq data class and has a property called PropertyOnLinqDataClass. You'll need to implement the INotifyPropertyChanged interface on the client side to properly support 2 way data binding.