WCF on Windows Mobile 6

E

eager2008

I have a "selfhosted" simple WCF service with 2 OperationContracts and 2
DataContracts. OperationContract no 1 only returns a DataContract no 1 and
OperationContract no 2 takes DataContract no 2 as argument and returns
nothing.
I.e. Contract 1 is about getting data from the service and no 2 is about
setting to ditto.
Binding is basicHttpBinding.
Getting works fine from a smartphone, but setting does not work, i.e. all
datamembers are 0 when they arrive the method on the service.
Anyone knows what is wrong ?
 
E

eager2008

Extra info:
Smartphone running Windows Mobile 6 Standard/Compact Framework 3.5
Service running on an XP machine with "Full Framework" 3.5

Setting data (sending to service) works fine from an XP/Server 2008 with
"Full Framework" 3.5 and generated by VS2008 (Svcutil ??), but as mentioned,
the Smartphone does not (and smartphone files were generated by NetCFSvcUtil.
 
C

Colbert Zhou [MSFT]

Hello Magne,

I can reproduce the same issue as you described on int type data member.
Actually, in my side, the NetCFSvcUtil tool generates the proxy class with
an additional property that has "Specified" suffix. And this property is
bool type. If we set this property to true, the related int data member
will be serialized and desterilized correctly.

For example, I have a DataContract Person with DataMember ID and Name.
After I use NetCFSvcUtil generate the proxy class, I get Person class with
three properties,

ID, int
Name, String
IDSpecified, bool

In our codes, to make the id value transfers to the server client, we need
to set the IDSpecified to true. See the following codes,

private void linkLabel1_Click(object sender, EventArgs e)
{
SetGetPersonServiceClient client = new
SetGetPersonServiceClient();
Person p = new Person();
p.IDSpecified = true;
p.ID = 38;
p.Name = "Colbert";
client.Set(p);
}

For more information on this, please read the following MSDN blog article.
http://blogs.msdn.com/eugeneos/archive/2007/02/05/solving-the-disappearing-d
ata-issue-when-using-add-web-reference-or-wsdl-exe-with-wcf-services.aspx

Please have a test and let me know if this resolves your problem! Have a
nice day!

Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
E

eager2008

Thanks a lot, I just saw these flags my self earlier today and it solved my
problem.
Why I have not seen this behaviour before ? It is quite a while ago since I
last programmed smartphone (at least using WCF or WS), probably back to when
the old serializer (Colbertz's link) was still the new one ... :)

I guess the reason for these flags is to be able to optimize the SOAP
message transmitted by resorting to the (value) type's default value.
 
C

Colbert Zhou [MSFT]

Hello Magne,

Yes. This Specified suffix property is designed to improve the flexibility
of DataMember's serialization. So, if the client want use default value for
that attribute, we just let the Specified property to false. So it will not
be serialized and the performance will be improved as you said.

Actually, if we want to work around this problem from the service server
side, we just mark the data member as IsRequired. So the NetCFSvcUtil tool
will not generate the Specified property.

[DataMember(IsRequired = true)]
public int ID
{
get { return id; }
set { id = value; }
}

Please let me know if you have any future questions on this. Have a nice
weekend!


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Joined
Mar 25, 2009
Messages
1
Reaction score
0
Desperate

Hi guys. I just came across your thread with Google. You can't image the crap I'm in. I'm trying to do what you did for hours now. I am desperate. It's been 5 hours of trying and trying and trying and I JUST CAN'T MAKE IT WORK. I can't even reach 20% of what you did.

I used netcfsvcutil to publish a service, but when I try to access it from the emulator or the windows mobile device (cradled in USB), I get the same error:

There was no endpoint listening at http://echysttas:8000/ServiceModelSamples/Service/Calc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

I'm pretty desperate here, please help if you can.

Here is how I create the Service. It's self hosted, just as you have it! I got it in a console application. Echysttas is the name of my computer. After I run the .Net CF thing on it, it creates CalculatorService.cs and CFClientBase.cs, but cannot find any "IsRequired" property in either.

You guys already worked with this EXACT same thing, I think it would be easy for you to explain me where I'm screwing this up.

Immense thanks for any help. Here is the code I was talking about before:

Uri baseAddress = new Uri("http://echysttas:8000/ServiceModelSamples/Service");
Uri Address = new Uri("http://echysttas:8000/ServiceModelSamples/Service/Calc");


BasicHttpBinding binding = new BasicHttpBinding();
binding.Name = "binding1";
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
binding.Security.Mode = BasicHttpSecurityMode.None;


ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);

try
{
selfHost.AddServiceEndpoint(typeof(ICalculator), binding, Address);

ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
selfHost.Description.Behaviors.Add(smb);


selfHost.Open();
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();

// Close the ServiceHostBase to shutdown the service.
selfHost.Close();
}
catch (CommunicationException e)
{
Console.WriteLine("An exception occurred: {0}", e.Message);
selfHost.Abort();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top