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
Solved

User Defined Data Type

Posted on 2012-03-15
5
464 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
  • 2
  • 2
5 Comments
 
LVL 84
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 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

808 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