Web Services, Infopath and managed code

E

ElVino

Lo again!!

Im in the process of coverting my Infopath application business logic into
VB .NET. I appear to have a problem accessing web services both as Data
Connections and as Web References.

I have the Web Services on another box on the same domain and I am using
Windows Integrated Authentication.

This worked fine using Infopath and Javascript but now with the manged code
I am getting " 401 Acces Denied"

The form was originally Fully trusted and I assume it still is with the .NET
version!!
 
E

Ed Richard

You will have to supply credentials to the Web Service using the credentials
property of the object you are using. Can you show us the VB code you are
using to make the call?

Ed Richard
 
E

ElVino

So much for integrated authentication!!

Public Sub Logon_cmdLogon_OnClick(ByVal e As DocActionEvent)

Dim oXMLDoc As IXMLDOMElement
'Dim oNode As IXMLDOMNode
Dim oRoot As IXMLDOMElement
Dim oLogon As New Logon.Logon
Dim oCredentail As NetworkCredential

Try
m_defaultDOM =
thisXDocument.DOM.documentElement.cloneNode(True)
oRoot =
thisXDocument.DOM.selectSingleNode("/ns1:document_element")

oXMLDoc =
oLogon.Logon(oRoot.selectSingleNode("./ns1:root/ns1:restaurant_id").text,
oRoot.selectSingleNode("./ns1:root/ns1:admin").text,
m_defaultDOM.selectSingleNode("./ns1:root").xml)
m_bEventsEnabled = False

oRoot.replaceChild(oXMLDoc.selectSingleNode("/dfs:myFields/dfs:dataFields/s0:LogonResponse/s0:LogonResult/my:root"), oRoot.selectSingleNode("./ns1:root"))
m_bEventsEnabled = True
thisXDocument.View.SwitchView("Home")
m_iRestaurantID =
oRoot.selectSingleNode("./ns1:root/ns1:restaurant_id").text

Catch ex As Exception

thisXDocument.UI.Alert(ex.Message)

End Try

End Sub
 
E

ElVino

Yay

Fixed it with a two liner!!

Logon.PreAuthenticate = True
oLogon.Credentials = System.Net.CredentialCache.DefaultCredentials
 

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