UTC(Z)12:28
EST07:28
CST06:28
MST05:28
PST04:28
Home Blogs Forums Photos Roller

Credentials in .NET

Last post 04-09-2009, 5:52 PM by agreen. 8 replies.
Sort Posts: Previous Next
  •  04-08-2009, 6:01 PM 1343

    Credentials in .NET

    Where are the credentials (email & key) provided in .NET?  I can't find anything in the WSDL. 

    The example provided in your "Hello Flight" is missing a lot of code.  What is "p"??

  •  04-08-2009, 6:17 PM 1344 in reply to 1343

    Re: Credentials in .NET

    Ok I've deduced that "p" is the type "PlaneXMLbeta1Soap". 

    Now the problem is that in the example "PlaneXMLbeta1Soap" has a "Credentials" property of type NetworkCredientials which is definately not a property in your distributed version.

    What's wrong?

  •  04-08-2009, 10:25 PM 1347 in reply to 1344

    Re: Credentials in .NET

    Hey Shawn! Sorry about that; you pointed out a typo in that code sample; that was my fault!

    Are you using Visual Studio to add a reference to the web service? In general, once the WSDL has been configured and added through VS, you then reference the web service as an instance class. The line:

    Dim PlaneXML As New com.fboweb.PlaneXMLbeta1

    Created the instance of the web service's class for you to use. The NetworkCredential references in the lines that follow are what allow you to add your email address and API key.

    Hope this helps; if you're still lost, give me some more details on your development environment and I'll help you out as best I can.
  •  04-09-2009, 1:02 PM 1355 in reply to 1347

    Re: Credentials in .NET

    Yes, I'm using VS.Net.

    In the WSDL I have, there is no reference to a "Credentials" property or method.  In other words, I can't find where to pass the username & API key in PlaneXMLbeta.

  •  04-09-2009, 1:09 PM 1357 in reply to 1355

    Re: Credentials in .NET

    The "Credentials" property is actually part of the proxy class that Visual Studio creates for you, not part of the actual WSDL.

    So, once you add the reference to the web service in VS, you then instantiate the proxy class with the following line (as referenced in the sample code):

    Dim PlaneXML As New com.fboweb.PlaneXMLbeta1

    Thats when you set the Credentials property:

    Dim c As New NetworkCredential("", "")
    PlaneXML.Credentials = c

    Do you have the first "dim" line (shown above) in your code?

  •  04-09-2009, 2:52 PM 1358 in reply to 1357

    Re: Credentials in .NET

    I appreciate your help with this...

     

    There is no "PlaneXMLbeta1" class - only a "PlaneXMLbeta1Soap" class.  This class does not provide a Credentials property.

    I even went throuh the WSDL & could not find any "Credentials" anywhere in the document.

     

    This is my current coding...

    Dim objXML As PlaneXML.PlaneXMLbeta1Soap = New PlaneXML.PlaneXMLbeta1SoapClient

    Dim objInfRequest As PlaneXML.FlightInfoRequest

    objInfRequest = New PlaneXML.FlightInfoRequest

    Dim objInfBody As New PlaneXML.FlightInfoRequestBody

    objInfBody.ident = "N5075Y" 'N5075Y

    objInfRequest.Body = objInfBody

    Dim objResponse As PlaneXML.FlightInfoResponse = objXML.FlightInfo(objInfRequest) 'Code errors here with:

    System.ServiceModel.Security.MessageSecurityException was unhandled
      Message="The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic Realm="fbowebRealm"'."
      Source="mscorlib"
      StackTrace:
        Server stack trace:
           at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory factory)
           at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException)
           at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
           at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
           at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
           at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
           at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
           at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
           at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
        Exception rethrown at [0]:
           at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
           at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
           at FBOWebAPI.PlaneXML.PlaneXMLbeta1Soap.FlightInfo(FlightInfoRequest request)
           at FBOWebAPI.PlaneXML.PlaneXMLbeta1SoapClient.PlaneXML_PlaneXMLbeta1Soap_FlightInfo(FlightInfoRequest request) in h:\Personal Folder\Visual Studio 2008\Projects\FBOWebAPI\FBOWebAPI\Service References\PlaneXML\Reference.vb:line 2534
           at FBOWebAPI.frmMain.frmMain_Load(Object sender, EventArgs e) in h:\Personal Folder\Visual Studio 2008\Projects\FBOWebAPI\FBOWebAPI\frmMain.vb:line 21
           at System.EventHandler.Invoke(Object sender, EventArgs e)
           at System.Windows.Forms.Form.OnLoad(EventArgs e)
           at System.Windows.Forms.Form.OnCreateControl()
           at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
           at System.Windows.Forms.Control.CreateControl()
           at System.Windows.Forms.Control.WmShowWindow(Message& m)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
           at System.Windows.Forms.ContainerControl.WndProc(Message& m)
           at System.Windows.Forms.Form.WmShowWindow(Message& m)
           at System.Windows.Forms.Form.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
           at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
           at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
           at System.Windows.Forms.Control.set_Visible(Boolean value)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.Run(ApplicationContext context)
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
           at FBOWebAPI.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: System.Net.WebException
           Message="The remote server returned an error: (401) Unauthorized."
           Source="System"
           StackTrace:
                at System.Net.HttpWebRequest.GetResponse()
                at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
           InnerException:

  •  04-09-2009, 3:44 PM 1359 in reply to 1358

    Re: Credentials in .NET

    Hmm; let me check a few things; are you using Visual Studio 2008 or 2005? Which .NET version are you using - 2.0, 3.0 or 3.5?

    I'm beginning to think you added the reference to the service as a "WCF" service. You should actually add it as a standard "Web Service" - that's what will give you the SOAP proxy that has the "Credentials" property.

    Specifically, when you add the reference, you want to add a "Web Reference", and not a "Service" reference.

    Let me know if this helps a bit...
  •  04-09-2009, 4:03 PM 1360 in reply to 1359

    Re: Credentials in .NET

    That was exactly it.  I'm running now. 

    Thank you for your patience.  Smile

  •  04-09-2009, 5:52 PM 1362 in reply to 1360

    Re: Credentials in .NET

    Not a problem at all, glad I could help!
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems