I appreciate any pointers to resolve this exception. This is my first WCF client on FEZ Spider, the WCF service is running on a PC in a Windows Service. It tested fine using a PC WCF client (I used Add Service Client in the PC version). The service is reachable from the Spider device and HttpWebRequest on the http://192.168.1.101:8000/TSGSCentral/?wsdl works fine and returns the correct wsdl xml text.
I followed the following steps:
- Generated the source files using MfSvcUtil from the WSDL file
- Added two of the three generated files to my project (did not add the xxxHostedService.cs)
- Added the framework assemblies to References (MFWsStack, MFDpwsExtensions, and MFDpwsClient)
- Added the following code to call a web service function that returns void, function name is Raise
The last line in this function generates the exception
void CallWSRaise()
{
Uri remoteEndPoint = new Uri("http://192.168.1.101:8000/TSGSCentral/AlarmService");
Ws.Services.Binding.HttpTransportBindingConfig config = new Ws.Services.Binding.HttpTransportBindingConfig(remoteEndPoint);
Ws.Services.Binding.WS2007HttpBinding binding = new Ws.Services.Binding.WS2007HttpBinding(config);
Ws.Services.ProtocolVersion version = new Ws.Services.ProtocolVersion10();
tempuri.org.IAlarmClientProxy client = new tempuri.org.IAlarmClientProxy(binding, version);
schemas.datacontract.org.TSGSCentralLib.Alarm alarm = new schemas.datacontract.org.TSGSCentralLib.Alarm();
alarm.DeviceId = Guid.NewGuid().ToString();
alarm.Code = 501;
tempuri.org.Raise raise = new tempuri.org.Raise();
raise.alarm = alarm;
client.Raise(raise);
}
Exception System.Xml.XmlException - 0x00000000 (1)
Message: Parsing Error. Type RaiseResponse must be present.
Ws.Services.Serialization.DataContractSerializer::ReadElement [IP: 004e]
Ws.Services.Serialization.DataContractSerializer::IsParentStartElement [IP: 000f]
tempuri.org.RaiseResponseDataContractSerializer::ReadObject [IP: 000a]
tempuri.org.IAlarmClientProxy::Raise [IP: 0066]
SpiderTestBench.Program::CallWSRaise [IP: 0052]
SpiderTestBench.Program::button_ButtonPressed [IP: 0022]
Gadgeteer.Modules.GHIElectronics.Button::OnButtonEvent [IP: 0057]
System.Reflection.MethodBase::Invoke [IP: 0000]
Gadgeteer.Program::DoOperation [IP: 001a]
Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054]
Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a]
Microsoft.SPOT.Dispatcher::Run [IP: 0006]
Gadgeteer.Program::Run [IP: 001d]
A first chance exception of type ‘System.Xml.XmlException’ occurred in MFWsStack.dll
The following PC Client Code (calling the same WCF Service) works fine:
//Step 1: Create an instance of the WCF proxy.
AlarmClient client = new AlarmClient();
// Step 2: Call the service operations.
// Call the Raise service operation.
Alarm alarm = new Alarm();
alarm.DeviceId = Guid.NewGuid();
alarm.Code = 3;
client.Raise(alarm);
//Step 3: Closing the client gracefully closes the connection and cleans up resources.
client.Close();