?
Solved

User Defined Data Type

Posted on 2012-03-15
5
Medium Priority
?
469 Views
Last Modified: 2012-03-16
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
Comment
Question by:CloudApps
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 85
ID: 37726449
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
 
LVL 75
ID: 37726668
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
 

Author Comment

by:CloudApps
ID: 37726876
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
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 37728622
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
 

Author Closing Comment

by:CloudApps
ID: 37730024
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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question