• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 474
  • Last Modified:

User Defined Data Type

I am trying to consume a webservice which requires that I pass 3 values as a single parameter. I have created a module in Access 2007 with the following code.
---------------------------------------------------------------------------------------------------------------------------
Option Compare Database
Option Explicit

Public Type UserIDBean
    UserName As String
    Password As String
    Version As String
End Type
--------------------------------------------------------------------------------------------------------------------------

Public Function TimesheetData(BeginningDate As Date, EndingDate As Date) As Variant
On Error GoTo HandleError

    Dim AdminIDBean As UserIDBean
    Dim objSoapClient As SoapClient30
    Dim varItems As Variant
   
    Set objSoapClient = New SoapClient30
   
    Call objSoapClient.MSSoapInit(par_WSDLFile:="https://timecardweb.econz.com/axis/services/timecard1Soap?wsdl")
    Call objSoapClient.EServiceTimecardSoapInterface.UserIDBean

    AdminIDBean.UserName = "webuser"
    AdminIDBean.Password = "webpassword"
    AdminIDBean.Version = objSoapClient.NADSWebserviceVersion.TIMECARD_VERSION_1

    TimesheetData = Array(objSoapClient.getDetailedHourSummaries(AdminIDBean, BeginningDate, EndingDate, "UTC-6"))

ExitHere:
    Exit Function

HandleError:
    MsgBox "The TimesheetData Function encountered an unexpected error. " & Chr(13) + Chr(10) & _
        "The Error Number is: " & Err.Number & Chr(13) + Chr(10) & _
        "The Error Description is: " & Err.Description, vbExclamation, "Error Handling Routine"
    Resume ExitHere

End Function
-------------------------------------------------------------------------------------------------------------------------------

Compile Error:

Only user-defined types defined in public object modules can be coerced to or from a variant or passed to late-bound functions.

The AdminIDBean is highlighted.

Thanks for the help.
0
CloudApps
Asked:
CloudApps
  • 2
  • 2
1 Solution
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
That would be expected - the web service has no way of know what your AdminIDBean is, or how it's constructed, or how to use it.

Do you have an documentation regarding the use of the web service, and what format it expects those values to come in?
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
I've only seen that error twice in my Access life of 19 years ... and both in the same week!

You might want to look HERE:

See the screen shot - where I got the exact same error, during testing of the issue.

mx
0
 
CloudAppsAuthor Commented:
LSMConsulting

UserIDBean Description

Each method call on the SOAP interface requires that the user name and password of an EService or Timecard organisation administrator be passed in for authentication purposes. The user will normally be the original administrator set up when the organisation was initially created.

The data fields of this object.

Name           Type    Size  Required Description
UserName   String  30    Yes            The user name of an administrator of the organisation.
Password     String  32    Yes            The password for the administrator.
Version        NADSWebserviceVersion
-----------------------------------------------------------------------------------------------------------------------------
Here is the webservice that I am trying to consume.

Methods to Retrieve Processed Data

Returns: Array of DetailedHourBreakdownBean

Method: getDetailedHourSummaries

Parameters: UserIDBean, start, end, showUserTZFlag

Description: Hourly breakdowns, adhering to the IDI specification, for all users in the given time period.
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I believe the web service you're working with requires you to connect with Java, not VBA/SOAP. Here's what I found from http://eservice.econz.co.nz/SOAP/timecardsoap1/nz/co/econz/nads/timecard1/Timecard1Soap.html#getDetailedUserHourSummary(nz.co.econz.nads.soap2.UserIDBean,%20java.lang.String,%20java.util.Calendar,%20java.util.Calendar,%20boolean)

getDetailedUserHourSummary(nz.co.econz.nads.soap2.UserIDBean userBean,
                                                            java.lang.String userPK,
                                                            java.util.Calendar startDate,
                                                            java.util.Calendar endDate,
                                                            boolean showUserTZFlag)
                                                            throws java.rmi.RemoteException

The UserBean datatype seems to be a class of some sort, so you might try instantiating a class and passing that in:

Dim UserIDBean As New userBean
UserIDBean.UserName = "MyUser"
UserIDBean.Password = "MyPassword"
UserIDBean.Version = "YourVersion"

Now pass in that class (although the compiler will probably deny that as well). I'm not sure this is how you declare the userBean class, since I don't have the documentation for it - or even if you CAN declare it.

As I said earlier, this appears to be a Java-based service. If that's the case, you won't be able to work with this from VBA.

Have you contacted the Econz people to see if they have any VB/VB examples of using the service?
0
 
CloudAppsAuthor Commented:
LSMConsulting,

There is a VB/SOAP version of the webservice.

I took your suggestion to built the UserIDBean as a class.

My code will compile now!

I still have issues consuming the webservice, but I think that the answers will have to come from Econz.

Thanks so much for your help and research.

Have a great weekend!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now