AGS call from .net to Lawson 9.0

Sort:
You are not authorized to post a reply.
Page 1 of 212 > >>
Author
Messages
John Polito
Advanced Member
Posts: 24
Advanced Member
    Before we upgraded to Lawson 9.0 i was able to do AGS call from my .net web application.
    I am now having security issues, can someone tell me the process now to pass the username and password in to the Credentials. Also i'm getting an error on servlet/ags saying that the servlet is not found.

    If you need more info just let me know!

    Thanks,
    John
    John Henley
    Senior Member
    Posts: 3348
    Senior Member
      You need to use a Java API to make the call ... see the LSF9 document "Doc for Developers: IOS Application Program Interfaces" chapter "Authenticating Programmatically to Lawson".
      Thanks for using the LawsonGuru.com forums!
      John
      John Polito
      Advanced Member
      Posts: 24
      Advanced Member
        Thanks John, I will take a look at the doc and see if i can figure this out.
        If I have questions I will post back to this thread.
        John Polito
        Advanced Member
        Posts: 24
        Advanced Member
          OK, now can you tell me why my ags isn't working.

          System.Web.HttpUtility.UrlEncode("http://server:80/cgi-lawson//servlet/ags?_PDL=PROD&_TKN=HR11.1&_EVT=CHG&FC=I&_LFN=ALL&_OUT=XML&EMP-EMPLOYEE=1111&EMP-COMPANY=1")
          John Henley
          Senior Member
          Posts: 3348
          Senior Member
            cgi-lawson//servlet/ags

            For Env 8, need to either use /cgi-lawson/ags.exe -or- /servlet/ags

            For LSF9, need to use /servlet/Router/Transaction/Erp
            Thanks for using the LawsonGuru.com forums!
            John
            John Polito
            Advanced Member
            Posts: 24
            Advanced Member
              Thanks again John that worked great!
              John Polito
              Advanced Member
              Posts: 24
              Advanced Member
                John since you seem to be the expert in this process I have another question.

                I am trying to do a PA52.1 through this process and I get my inquiry to work OK but when I go to post the change it is saying that I haven't done the inquiry yet. Do you know by chance how I can get it recognize that the inquiry was done?
                John Polito
                Advanced Member
                Posts: 24
                Advanced Member
                  John here is my http string;

                  http://webserver:80/servl...CT-NEW-VALUE-1r1=222
                  John Henley
                  Senior Member
                  Posts: 3348
                  Senior Member
                    PA52 is a tough one, particularly if this is your first foray into AGS calls. You need to populate HK (hidden key) field as well as perhaps some new fields prefixed by ORIG- (e.g. ORIG-COMPANY, ORIG-EMPLOYEE). See Lawson KB article 556226 for info on using Addins; you would do the same thing in AGS (since under the covers, Addins is really just AGS calls...)
                    Thanks for using the LawsonGuru.com forums!
                    John
                    jangins101
                    Basic Member
                    Posts: 10
                    Basic Member
                      Hey, I have a question about developing an application that can connect and execute an AGS call on Lawson 9. My question is whether or not it's doable through .NET (somehow interacting with java) or anything...
                      John Polito
                      Advanced Member
                      Posts: 24
                      Advanced Member

                        Hi jangins101,

                        I have written a VB.Net application that creates a number of Personnel Actions and connects to Lawson to apply them.  It is tricky to do so if need any help let me know.

                        John P.

                        jangins101
                        Basic Member
                        Posts: 10
                        Basic Member
                          I actually do. I am completely stumped in trying to integrate a VB.net app to Lawson. We have a number of console applications that need to integrate with Lawson, and I've done everything I can think of with no luck. If you could help, it'd be greatly appreciated.
                          (Note: the applications are actually written in VB6, but can probably be simply upgraded to VB.NET, so a method for either of those would be appreciated.)

                          Thanks,
                          John Polito
                          Advanced Member
                          Posts: 24
                          Advanced Member

                            Ok, explain to me what your trying to do, and what you have gotten to work so far.

                            jangins101
                            Basic Member
                            Posts: 10
                            Basic Member
                              Well, waht I've been trying to do is use the .NET HttpWebRequest/HttpWebResponse objects to make a call to the sso/SSOServlet using some POST parameters including the ones I found on the acual logon page. (and most importanatly the _ssoOrigUrl field). However, when I try to get the response from that particular HttpWebRequest, i get an error, 500 Internal Server Error.

                              That's waht I've done so far. Now, in the end, the entire purpose is do have a VB.NET windows/console application that will generate an AGS call, and then execute that call with Lawson, and get back the XML response, (For example, an AGS call performing an Inquire). That's the ultimate goal.

                              Thanks for the help!
                              John Polito
                              Advanced Member
                              Posts: 24
                              Advanced Member

                                OK here is how i am connecting,

                                 

                                Public Overridable Function SubmitPAtoLawson(ByVal http As String)Dim mainReq, LoginReq As HttpWebRequestDim cred As NetworkCredentialDim mainResp, LoginResp As HttpWebResponseDim qryReturn As String

                                 

                                 

                                 

                                Dim mainStream, loginStream As StreamReaderDim xmlDoc As XmlDocumentDim postData As String

                                 

                                 

                                 

                                Dim postStream As StreamWriterDim cookies As CookieContainerConst LAWSON_UID As String = "xxxxx" ' must be set to a valid employee with an RD30

                                 

                                Const LAWSON_PWD As String = "xxxxxxxx" ' must be the above user's password

                                loginStream =

                                Nothing

                                mainResp =

                                Nothing

                                mainStream =

                                Nothing

                                 

                                Try

                                cred =

                                 

                                New NetworkCredential(LAWSON_UID, LAWSON_PWD)' Send a GET request to the Lawson login page (need to get a session cookie)

                                LoginReq = WebRequest.Create(

                                LoginReq.Method =

                                "http://xxxlawweb02.com/lawson/portal/")"GET"

                                 

                                ' UserAgent MUST be set or an HTTP 500 error is returned

                                LoginReq.UserAgent =

                                "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)"

                                LoginResp = LoginReq.GetResponse

                                cookies =

                                LoginReq.CookieContainer = cookies

                                LoginResp.Cookies = LoginReq.CookieContainer.GetCookies(LoginReq.RequestUri)

                                 

                                New CookieContainerTry

                                loginStream =

                                qryReturn = loginStream.ReadToEnd

                                 

                                New StreamReader(LoginResp.GetResponseStream)Finally

                                 

                                 

                                If Not IsNothing(loginStream) Then loginStream.Close()'Else

                                 

                                ' ActionReturnMsg = "Unable to Login to Lawson. " & loginStream.ToString

                                 

                                ' ActionReturnCode = "006"

                                 

                                ' loginStream.Close()

                                 

                                 

                                If Not IsNothing(LoginResp) Then LoginResp.Close()'Else

                                 

                                'ActionReturnMsg = "Invalid Response from Lawson. " & LoginResp.ToString

                                 

                                'ActionReturnCode = "007"

                                 

                                'LoginResp.Close()

                                 

                                'End If

                                 

                                End Try

                                 

                                ' Next send a POST request to the Lawson SSO servlet

                                mainReq = WebRequest.Create(

                                mainReq.Method =

                                "http://xxxlawweb02.com/sso/SSOServlet")"POST"

                                mainReq.ContentType =

                                "application/x-www-form-urlencoded"

                                mainReq.Credentials = cred

                                mainReq.PreAuthenticate =

                                True

                                mainReq.Headers.Add(HttpRequestHeader.AcceptLanguage,

                                 

                                "en-us")'USERAGENT MUST BE SET OR AN HTTP 500 ERROR WILL BE RETURNED

                                mainReq.UserAgent =

                                "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)"

                                 

                                ' build the string of POST data for the SSO Servlet.

                                 

                                ' Note the _ssoOrigUrl parameter is what Lawson will redirect to and return XML from.

                                postData =

                                System.Web.HttpUtility.UrlEncode(http)

                                 

                                "_ssoUser=" & LAWSON_UID & "&_ssoPass=" & LAWSON_PWD & "&_action=LOGIN&_fromLoginPage=FALSE&_language=en-us&_ssoOrigUrl=" & _' pass in the cookie container obtained from the LOGIN PAGE (critcal)

                                mainReq.CookieContainer = cookies

                                mainReq.ContentLength = Len(postData)

                                 

                                ' Write the POST data to the stream

                                postStream =

                                 

                                New StreamWriter(mainReq.GetRequestStream)Try

                                postStream.Write(postData.ToString)

                                 

                                Finally

                                postStream.Close()

                                 

                                End Try

                                 

                                'Get the data as an HttpWebResponse object

                                mainResp = mainReq.GetResponse()

                                 

                                ' Convert the data into a string (assumes that you are requesting text)

                                mainStream =

                                qryReturn = mainStream.ReadToEnd()

                                 

                                New StreamReader(mainResp.GetResponseStream())' load an XML doc with the returned data.

                                xmlDoc =

                                xmlDoc.LoadXml(qryReturn.ToString)

                                 

                                 

                                New XmlDocumentReturn xmlDocIf IsNothing(xmlDoc) Then

                                ActionReturnMsg =

                                "Unable to execute Lawson API."

                                ActionReturnCode =

                                "001"

                                 

                                Return Nothing

                                 

                                End If

                                 

                                ActionReturnMsg =

                                ActionReturnCode =

                                Catch ex As WebException"Unable execute Lawson DME call. " & ex.Message"002"

                                 

                                Return Nothing

                                 

                                 

                                Catch ex As Exception' unable to execute against the api

                                ActionReturnMsg =

                                ActionReturnCode =

                                "Unable execute Lawson DME call. " & ex.Message"003"

                                 

                                Return Nothing

                                 

                                Finally

                                 

                                End

                                Try

                                 

                                End Function
                                ' clean up open items

                                Let me know if this makes sense.

                                John P.

                                 

                                 

                                 

                                 

                                jangins101
                                Basic Member
                                Posts: 10
                                Basic Member
                                  hey, could you email me a .vb file containing that code? I'm having a little bit of trouble parsing it myself. Couple things I'm not getting. email= mjenkins@imb.org

                                  thanks!
                                  jangins101
                                  Basic Member
                                  Posts: 10
                                  Basic Member
                                    Ok. Nevermind. I was able to get it successfully. Thank you SO much for the help. It worked perfectly! I really do appreciate it!
                                    John Polito
                                    Advanced Member
                                    Posts: 24
                                    Advanced Member
                                      Your welcome.
                                      tejkamat
                                      New Member
                                      Posts: 1
                                      New Member
                                        Hi John Polito,

                                        I am having a weird issue where the call to the servlet is returning html for the login page instead of xml. I am using xmlhttp and it returns xml on one server and html on the other which is causing issues. Can you please post ur code again, the format is all messed up.

                                        Thanks,
                                        John Polito
                                        Advanced Member
                                        Posts: 24
                                        Advanced Member
                                          Sorry this has taken me so long to get back to you, I have been really busy. Do you still need the code?
                                          ggould
                                          Basic Member
                                          Posts: 4
                                          Basic Member
                                            John,

                                            I am having the same problem as tej. I was sending the AGS call through a "XMLHTTPRequest" in VB. Now that we've upgraded to 9, I'm having nothing but problems. Would you have any suggestions or sample code available?

                                            Thanks,
                                            Greg
                                            darwincollins
                                            Posts: 3
                                              We were able to get it to work via xmlhttp. Please let me know if you need some info. Thanks
                                              lgopireddy
                                              Basic Member
                                              Posts: 6
                                              Basic Member
                                                John,

                                                Can you send me JAVADOC,i am trying to write program in java to connect to lawson9
                                                Kwane McNeal
                                                Veteran Member
                                                Posts: 479
                                                Veteran Member
                                                  Another method would be to use lhc.jar
                                                  Shawn
                                                  New Member
                                                  Posts: 1
                                                  New Member

                                                    John, Thank you very much for posting your sample code.  We are upgrading from 8.02 to LSF9 and we have around 10 applications that used to use the Lawson COM+ along with VB6 in 8.02 and your code example has given us an excellent starting point for converting all of these applications.   You have saved us a lot of research and otherwise wasted time.  

                                                    Thank you again,
                                                    Shawn

                                                    You are not authorized to post a reply.
                                                    Page 1 of 212 > >>