maybe i am dot using web services corretcly - InfoPath Dev
in

InfoPath Dev

maybe i am dot using web services corretcly

Last post 05-16-2007 01:25 AM by basescu. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-09-2007 05:59 AM

    maybe i am dot using web services corretcly

    Hello.

    I use a web service to qery the AD to get the givenname and the surname of the preson hwo opens the form. The form is published on sharepoint. When someone wants to fill a form, he goes on sharepoint, on the form library and clicks on "fill this form". I want that the givenname and the surname of theperson that opens the form to be completed on load.

    So in my infopath project made in vs 2005 with c# i added a web reference to the web service. This reference is named SP2007.

    The web service contains two web methods

    string GetSurname(string userName){}

    string GetGivenName(string userName){}

    And  then i add a on_load event, end write code to complete the textboxes with the strings returned by methods:

    public void OnLoad(DocReturnEvent e)

    {

    // Write your code here.

    string userName = System.Environment.UserName;

    sp2007.Service serviciu= new sp2007.Service();

    string nume = serviciu.GetNume(userName);

    void OnLoad(DocReturnEvent e)

    {

    // Write your code here.

    string userName = System.Environment.UserName;

    sp2007.Service serviciu= new sp2007.Service();

    string nume = serviciu.GetNume(userName);

    // Write your code here.

    string userName = System.Environment.UserName;

    sp2007.Service serviciu= new sp2007.Service();

    string nume = serviciu.GetNume(userName);

    string userName = System.Environment.UserName;

    sp2007.Service serviciu= new sp2007.Service();

    string nume = serviciu.GetNume(userName);

    Service serviciu= new sp2007.Service();

    string nume = serviciu.GetNume(userName);

    string nume = serviciu.GetNume(userName);

    thisXDocument.DOM.selectSingleNode("/my:myFields/my:nume").text =serviciu.GetSurname(userName);

    thisXDocument.DOM.selectSingleNode("/my:myFields/my:prenume").text = serviciu.GetGivenname(userName);

    "/my:myFields/my:nume").text =serviciu.GetSurname(userName);

    thisXDocument.DOM.selectSingleNode("/my:myFields/my:prenume").text = serviciu.GetGivenname(userName);

    "/my:myFields/my:prenume").text = serviciu.GetGivenname(userName);

    }

    ok

    that is all my code.

    I am not using any data connections. I am not using WebServiceAdapter2 or anything like that. is it a problem? Should have i use these?

    The thing is when i run the form from within vs2005 all works fine. After i published on sharepoint the web service doesn't work.

    I get this:

    System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.CodeAccessPermission.Demand() at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint) at System.Net.HttpRequestCreator.Create(Uri Uri) at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) at System.Net.WebRequest.Create(Uri requestUri) at System.Web.Services.Protocols.WebClientProtocol.GetWebRequest(Uri uri) at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest(Uri uri) at System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest(Uri uri) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at CerereInvoire.sp2007.Service.GetNume(String userName) at CerereInvoire.CerereInvoire.OnLoad(DocReturnEvent e) The action that failed was: Demand The type of the first permission that failed was: System.Net.WebPermission The Zone of the assembly that failed was: Intranet

     

    Please help me a little. i am stuck.

    Basescu

  • 05-10-2007 01:36 AM In reply to

    • ahardin
    • Top 200 Contributor
    • Joined on 02-13-2006
    • United Kingdom
    • Posts 55

    Re: maybe i am dot using web services corretcly

    system.environment.username only works on fully trusted forms outside of VStudio.

    I run this internally with a VB web service and get it to work but need help converting it to C# so perhaps we can swap ideas?

    What i did was add a data connection, select receive data, select web service, then type in the .....asmx?WSDL location and click next, name the connection and click finish.

    Now I add the code below to my form to pull off the detail i need then go in Tools - Form Options - Open and Save - Rules add a rule that says if CONDITION X (where condition X only occurs on the opening of the form) set @FieldA to (Secondary Data Source Web Service) Given Name, @FieldB to sn and so on.  Works a treat 

    Sub XDocument_OnLoad(eventObj) Set xmlFirstName = XDocument.DOM.SelectSingleNode("/my:myFields/my:req_first_name") Set xmlLastName = XDocument.DOM.SelectSingleNode("/my:myFields/my:req_last_name") Set xmlTitle = XDocument.DOM.SelectSingleNode("/my:myFields/my:req_title") Set xmlMail = XDocument.DOM.SelectSingleNode("/my:myFields/my:req_email") Set xmlDepartment = XDocument.DOM.SelectSingleNode("/my:myFields/my:req_dept_num") End Sub

    Any chance you could send me the code for this query in C#?

    This way no extra coding and Infopath handles all the tricky bits.

    Any problems I am here to help.

    Adam

    I'm from WALES
    [email protected]
  • 05-16-2007 01:25 AM In reply to

    Re: maybe i am dot using web services corretcly

    First of all thank u for your response, but system.environment.username works in forms not fully trusted.

    Then i must say that giveing me vb code doesn't help me very much because i don't know it.

    I don't know what code u want. If u explain me more maybe i can.

    :)

    Basescu

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.