I am having difficulty getting my Raptor with ENC28 to connect to a simple WCF Service.
I am not sure what all code is relevant to post, as there is quite a bit when I add in all of the WCF. I can make the solution available.
My main program.cs
using System;
using Microsoft.SPOT;
using GHI.Premium.Net;
using Gadgeteer.Networking;
using Ws.Services;
using Ws.Services.Binding;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using tempuri.org;
namespace RaptorNetwork
{
public partial class Program
{
private IService1ClientProxy _proxy;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
/*******************************************************************************************
Modules added in the Program.gadgeteer designer view are used by typing
their name followed by a period, e.g. button. or camera.
Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
button.ButtonPressed +=<tab><tab>
If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
timer.Tick +=<tab><tab>
timer.Start();
*******************************************************************************************/
// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
Debug.Print("Program Started");
InitializeNetwork();
button.TurnLEDOn();
button.ButtonPressed += button_ButtonPressed;
}
void Program_ResponseReceived(HttpRequest sender, HttpResponse response)
{
if (response.StatusCode == "200")
{
Debug.Print(response.Text);
}
else
{
Debug.Print("HTTP-Response: " + response.StatusCode);
}
}
#region Events
void button_ButtonPressed(Button sender, Button.ButtonState state)
{
Debug.Print("Button Pressed");
CallServiceTest();
}
private void CallServiceTest()
{
WebClient.GetFromWeb("http://www.newegg.com/").ResponseReceived += Program_ResponseReceived;
GetData getData = new GetData
{
value = 1112
};
GetDataResponse getDataResponse = _proxy.GetData(getData);
Debug.Print(getDataResponse.GetDataResult);
}
void Interface_CableConnectivityChanged(object sender, EthernetENC28J60.CableConnectivityEventArgs e)
{
Debug.Print("Cable " + (e.IsConnected ? "is " : "is not ") + "connected.");
}
void Interface_NetworkAddressChanged(object sender, EventArgs e)
{
Debug.Print("Network Address Changed.");
Debug.Print("IP Address: " + ethernetENC28.Interface.NetworkInterface.IPAddress);
if (ethernetENC28.Interface.IsActivated)
{
InitializeService();
CallServiceTest();
}
}
#endregion
#region Initializers
private void InitializeNetwork()
{
ethernetENC28.Interface.Open();
ethernetENC28.Interface.NetworkInterface.EnableDhcp();
ethernetENC28.Interface.NetworkInterface.EnableDynamicDns();
NetworkInterfaceExtension.AssignNetworkingStackTo(ethernetENC28.Interface);
ethernetENC28.Interface.NetworkAddressChanged += Interface_NetworkAddressChanged;
ethernetENC28.Interface.CableConnectivityChanged += Interface_CableConnectivityChanged;
}
private void InitializeService()
{
WS2007HttpBinding binding = new WS2007HttpBinding(new HttpTransportBindingConfig(new Uri("http://vmsp1.idontexist.local:5598/Service1.svc/wsHttp")));
_proxy = new IService1ClientProxy(binding, new ProtocolVersion11());
}
#endregion
}
}
I can add more if anyone wants to see specific files.
when I make a call _proxy.GetData(getData); I am getting the following exception.
Exception Ws.Services.Faults.WsFaultException - 0x00000000 (5)
#### Message:
#### Ws.Services.Faults.WsFault::ThrowFaultException [IP: 01fc] ####
#### Ws.Services.WsaAddressing.WsWsaHeader::ParseHeader [IP: 01d3] ####
#### Ws.Services.Encoding.TextMessageEncodingBindingElement::OnProcessInputMessage [IP: 01fc] ####
#### Ws.Services.Binding.BindingElement::ProcessInputMessage [IP: 0019] ####
#### Ws.Services.Binding.RequestChannel::ReceiveMessage [IP: 002c] ####
#### Ws.Services.Binding.RequestChannel::Request [IP: 0017] ####
#### tempuri.org.IService1ClientProxy::GetData [IP: 0047] ####
#### RaptorNetwork.Program::CallServiceTest [IP: 002a] ####
#### RaptorNetwork.Program::Interface_NetworkAddressChanged [IP: 003a] ####
#### GHI.Premium.Net.NetworkInterfaceExtension::NetworkChangeExtension_NetworkAddressChanged [IP: 0021] ####
#### GHI.Premium.Net.NetworkChangeExtension::OnNetworkChangeCallback [IP: 00ac] ####
#### GHI.Premium.Net.NetworkChangeExtension+NetworkChangeExtensionListener::OnEvent [IP: 000d] ####
#### Microsoft.SPOT.EventSink::EventDispatchCallback [IP: 0014] ####
A first chance exception of type âWs.Services.Faults.WsFaultExceptionâ occurred in MFWsStack.dll
An unhandled exception of type âWs.Services.Faults.WsFaultExceptionâ occurred in MFWsStack.dll
Uncaught exception
The thread ââ (0x7) has exited with code 0 (0x0).
#### Exception System.OutOfMemoryException - CLR_E_OUT_OF_MEMORY (1) ####
#### Message:
#### System.Text.UTF8Encoding::GetChars [IP: 0000] ####
#### Gadgeteer.Networking.HttpResponse::get_Text [IP: 0019] ####
#### Gadgeteer.Networking.HttpRequest::OnResponseReceivedEvent [IP: 0036] ####
#### 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: 0020] ####
A first chance exception of type âSystem.OutOfMemoryExceptionâ occurred in mscorlib.dll
Could not decode the requested data and create text
The thread ââ (0x9) has exited with code 0 (0x0).
Has anyone come across this error, or does it look familiar? I was not able to find anything relevant in my googling or here on the forums.
Right now, the WCF service is hosted on an IIS * box that I have hosted on my network. Security is set up to allow anonymous connections and I can hit it without issue on a network-conected but non-domain joined computer, so I do not believe that it is IIS security or firewall.