Link to home
Start Free TrialLog in
Avatar of chow_cheska
chow_cheska

asked on

webservice: problem with enumerated element in xsd class vb.net vs2005

the xsd:
  <xs:element name="IndividualUpdateListResponse">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="tns:ResponseRecordAttributes" />
        <xs:element name="IndividualUpdateListResponseItem" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="tns:qts_incident_id" />
              <xs:element ref="tns:qts_message_id" />
              <xs:element ref="tns:title" />
              <xs:element ref="tns:log_date" />
              <xs:element ref="tns:isOriginal" />
              <xs:element ref="tns:direction" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>


the xml
<response systype="success" sysmessage="noerror" sysaction="view_individualupdate_list">
  <IndividualUpdateListResponse>
    <IndividualUpdateListResponseItem>
       <qts_incident_id>string</qts_incident_id>
       <qts_message_id>string</qts_message_id>
       <title>string</title>    
       <log_date>string</log_date>
       <log_date>string</log_date>
       <direction>string</direction>    
    </IndividualUpdateListResponseItem>  
    <IndividualUpdateListResponseItem>
       <qts_incident_id>string</qts_incident_id>
       <qts_message_id>string</qts_message_id>
       <title>string</title>    
       <log_date>string</log_date>
       <log_date>string</log_date>
       <direction>string</direction>    
    </IndividualUpdateListResponseItem>  
  </IndividualUpdateListResponse>
</response>


my problem:

I can't reference IndividualUpdateListResponseItem through IndividualUpdateListResponse
I can 't reference qts_incident_id through IndividualUpdateListResponseItem


I would expect to be able to reference
response.IndividualUpdateListResponse.IndividualUpdateListResponseItem.qts_incident_id


I can't get to elements under IndividualUpdateListResponseItem ...?
the xsd.exe (vs2005)  built IndividualUpdateListResponseIndividualUpdateListResponseItem but I don't understand how to use it?
do I somehow add IndividualUpdateListResponseIndividualUpdateListResponseItem to IndividualUpdateListResponse myself?

I've attached the XSD classes and the build/bind from my dataClass

I need to build the response and build the itemListing by iterating through a datareader.
the dr returns 0 or more rows, 1 IndividualUpdateListResponseItem is built for each row ...

XSD-classes1-5.vb
DataClass.vb
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

I would think that you need array indexes:

    response.IndividualUpdateListResponse.IndividualUpdateListResponseItem(0).qts_incident_id

Avatar of chow_cheska
chow_cheska

ASKER

ah, thank you sir!

that should mean that I can do something to the effect of:

        Try
            dr = MyCommand.ExecuteReader()
            Dim i As Integer = 0
            While dr.Read
                response.IndividualUpdateListResponseItem(i).qts_incident_id = dr(0)
                response.IndividualUpdateListResponseItem(i).qts_message_id = dr(1)
                response.IndividualUpdateListResponseItem(i).title = dr(2)
                response.IndividualUpdateListResponseItem(i).log_date = dr(3)
                response.IndividualUpdateListResponseItem(i).direction = dr(4)
                response.IndividualUpdateListResponseItem(i).isOriginal = dr(5)
                i = i + 1
            End While
            dr.Close()
        Catch ex As Exception
            response.ResponseRecordAttributes.systype = "fail"
            response.ResponseRecordAttributes.sysmessage = "cannot perform list query. " & ex.Message
            response.ResponseRecordAttributes.responseAction = "IndividualUpdateList"
            dr.Close()
        End Try

I shall plug it in today!

by the way - for more points of course, do you know the easiest way to debug a (this) webservice?
... without building a full test consumer ...

Is there any way to just pass in an xml string while in debug mode?


When I build a web service, I usually have a test web client in the same solution.  That way, you can step through the client code, into the web methods, to track down problems.  There might be another approach, but I haven't needed to find one.

I would think that, if that syntax works, it looks good to me.   The only thing that I could suggest is that I don't like ordinal index when referencing columns on a data reader.  You can use field names in place of index numbers to reference fields.

dr(0) doesn't make any sense, and dr("IncidentID") makes much more sense.
Thanx!
I see your point and agree about the referencing columns.
I'm quite a beginner, given so - what's the best way to build a test web client inside the service?
should I
- create a sub project inside existing project
- reference the xsd classes
- build functions for requests (with fixed vlaues)
- button clicks call functions
- functions return requests ...
? how do I submit the requests to the webservice? <- from each function?
? as a consumer - could I import the wsdl - and what would that actually do for me?

sorry - but I could use a good point into the right direction ...


Hmmm...best way...best way...(thinking)...

I would say that the way that I achieve this goal may not be the "best" way but it is at least one way.

1) Run the web service on the localhost IIS.

2) Add a Windows Forms application (easier to work with than an ASP.NET web site project)  to the solution.

3) Add a web reference to the localhost web service.

4) Create a form that creates an instance of the web service proxy class that is generated when you add a web reference.

5) Create some stress test methods on the form--add any necessary UI elements to trigger tests.

6) Another approach, if you have the capability, is to create a test project (Team Suite edition or NUnit).
would you choose a web forms app or a test project?
I can create a test project - but I've never worked with one.
well, I've never made a windows form app either ... I've only worked with asp.net vb.net ...

with a test project could I automate processes?
it looks like I can run tests and test views, I created a dummy test project. But I don't have 'Team Edition for Software Testers'

the webservice has 4 methods, so it's not relaly 'big' at all.

You just need something that can give you a way to step into web methods to troubleshoot, so the decision is really up to you.  I prefer Windows Forms applications, because they are easy to create, but you are certainly free to use a test project, or a web site.
ok, so referring to your numbers above,
1 - done
2 - done - named QtsService.Test and with class Test
3 - done - named localhostQtsService
4- I use the imports call to the webreference - i get this:
Imports QtsService.Test.localhostQtsService ... is that right?

I also added a project reference to the assemblies project which contains my xsd classes ... so I can build the xml requests

looks like this:
-------------------------------------------
Imports QtsService.Assemblies
Imports QtsService.Test.localhostQtsService


Public Class test

    Public Function test_CreateInquiry() As InquiryCreateRequest

        Dim request As New InquiryCreateRequest

        request.InquiryCreateRecord.category = "Accounts"
        request.InquiryCreateRecord.type = "Entries"
        request.InquiryCreateRecord.title = "help with problem"
        request.InquiryCreateRecord.comments = "this is my question"
        request.InquiryCreateRecord.email = "me@this.com"
        request.InquiryCreateRecord.phone_nr = "+46 22 123 348"
        request.InquiryCreateRecord.ext_clientpty_id = "12341234123412"
        request.InquiryCreateRecord.ext_clientpty_name = "Client Industries"
        request.InquiryCreateRecord.ext_user_id = "x12345"
        request.InquiryCreateRecord.ext_user_name = "Peter ClientMan"
        request.InquiryCreateRecord.country = country.SE

        Return request

    End Function


    Private Sub test_create_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles test_create.Click
        test_CreateInquiry()
    End Sub

End Class
-------------------------------------------

does this look like it makes sense? How do I send this to the webservice ?
I'll up the points to whatever you like if you can help me get through the set up of the debugger ! Not only that but you would be savin my but too!
I know it's more than i started out with ... but i do so appreciate the help!
In order to debug the web service, you just need to place a breakpoint on the line where you have a call to a web method in the client code.  Since your web service code is loaded in the IDE as part of the solution, the debugger should recognize that, and step through the web method call.  
Yep, I understand about the breakpoint and step through. But how do I actually call the web method from the consumer. I've attached the wsdl file (change txt to wsdl) as reference.

A method in the service is RetrieveInquiryCreateRequest
but that's not in intellisense ... among other things in intellisense are RetrieveInquiryCreateRequestRequest

also, I tried
      Dim request As New localhostQtsService.RetrieveInquiryCreateRequestRequest

        request.RequestRecordAttributes.requestAction = "InquiryCreateRequest"
     . . . . . .
in debug I get the error NullReferenceException
Object reference not set to an instance of an object.
but i instanciated it with new ..?

you think you can help me with the actual syntax to call the webmethod and to pass it the parameters?
QtsService.txt
That sounds like you are not working with the web service correctly.  If you look at the WSDL file, you can see data elements (objects), like RetrieveInquiryCreateRequest, RetrieveInquiryCreateRequestResponse, etc.  There are also web methods listed:

RetrieveInquiryCreateRequest
<wsdl:message name="RetrieveInquiryCreateRequestSoapIn">
    <wsdl:part name="parameters" element="tns:RetrieveInquiryCreateRequest" />

RetrieveInquiryUpdate
<wsdl:message name="RetrieveInquiryUpdateSoapIn">
    <wsdl:part name="parameters" element="tns:RetrieveInquiryUpdate" />
  </wsdl:message>

Each request method has a corresponding response object (RetrieveInquiryCreateRequestResponse, RetrieveInquiryUpdateResponse).  

Is there some kind of documentation (3rd party web service), or do you have control over the web service?
it's my webservice - just finished it.
coding wise the entire webservice producer and 'response' methods worked ok. The only problem I had was what started this thread ... but you took care of that ..

it doesn't feel right on the request side. maybe the web reference function didn't work well. What files can i upload which would help you see it better?

that wsdl i uploaded was created from the web reference on the consumer side - I compared it to the produecr wsdl and they are identical ...
You can show me a web method, and tell me what it is supposed to do...
ok, so  - the service itself resides in my main project, QTS. the webmethod then calls a processManager in a subproject called businessLogic. the processManager works it through and itself calls another subproject - DataAccess, where the db queries reside, DataAccess calls SP's  ...
btw this is a support system - an inquiry management system. Until now every new inquiry was created and inside the system. this function receives an inquiry 'creation' from another application, which will then continue to be managed within the system.

so - the web method - under services/QtsService.asmx:
--------------------------------
    <WebMethod()> _
    <Description("create a new inquiry investigation instance")> _
    Public Function RetrieveInquiryCreateRequest(ByVal request As InquiryCreateRequest) As InquiryCreateResponse
            Dim manager As New BusinessProcessManager()
            Return manager.RetrieveInquiryCreateRequest(request)
    End Function
-----------------------------

the processManager:
-----------------------------
Public Function RetrieveInquiryCreateRequest(ByVal request As InquiryCreateRequest) As InquiryCreateResponse

        'REQUEST
        ' + required +
        'country
        'category
        'type
        'title
        'comments
        'ext_clientpty_id

        ' - optional -
        'ext_clientpty_name
        'ext_user_id
        'ext_user_name
        'email
        'phoneNr
        'int_user_id




        'RESPONSE
        ' + required +
        'qts_incident_id
        'acknowledge


        Dim response As New InquiryCreateResponse

        Dim access As New QtsService.DataAccess.DataClass






        'resolve Client
        Dim myClientId As String = access.ResolveClientId(request.InquiryCreateRecord.ext_clientpty_id)
        If myClientId = "fail" Then
            response.ResponseRecordAttributes.systype = "fail"
            response.ResponseRecordAttributes.sysmessage = "qts service fail: cannot resolve client ID."
            response.ResponseRecordAttributes.responseAction = "InquiryCreate"
            Return response
        End If

        'resolve team [ROUTING]
        Dim myTeamId As String
        If Not myClientId = "fail" And Not myClientId = "14234" Then '14234 = External Non-QTS Client
            'we have a client already existing in QTS
            myTeamId = Routing(request.InquiryCreateRecord.ext_clientpty_id, CStr(request.InquiryCreateRecord.country), request.InquiryCreateRecord.type) 'we still send the 14 digit kurrenr to Routing
        Else
            'client is unresolvable = force route to EBS SE
            myTeamId = "72"
        End If


        'resolve category
        Dim myCategoryId As String = access.ResolveCategoryId(request.InquiryCreateRecord.category, myTeamId)
        If myCategoryId = "fail" Then
            response.ResponseRecordAttributes.systype = "fail"
            response.ResponseRecordAttributes.sysmessage = "qts service fail: cannot resolve category ID"
            response.ResponseRecordAttributes.responseAction = "InquiryCreate"
            Return response
        End If


        'resolve type
        Dim myTypeId As String = access.ResolveTypeId(request.InquiryCreateRecord.type, myCategoryId)
        If myTypeId = "fail" Then
            response.ResponseRecordAttributes.systype = "fail"
            response.ResponseRecordAttributes.sysmessage = "qts service fail: cannot resolve type ID"
            response.ResponseRecordAttributes.responseAction = "InquiryCreate"
            Return response
        End If


        'resolve owner_person
        Dim myOwnerPerson As String = access.ResolveOwnerPersonId(myTeamId, request.RequestRecordAttributes.submitting_app_qtsid)
        If myOwnerPerson = "fail" Then
            response.ResponseRecordAttributes.systype = "fail"
            response.ResponseRecordAttributes.sysmessage = "qts service fail: cannot resolve owner_person_id"
            response.ResponseRecordAttributes.responseAction = "InquiryCreate"
            Return response
        End If


        'resolve uid
        Dim myUid As String = IncidentNr(myOwnerPerson)



        'to create incident from external app we:
        'insert inquiry   (inquiry details)
        'insert inquiry_work   (work/response time details)
        'insert inquiry_workinprogress   (investigation creation)
        'insert externalWipDetails   (external app details and association to investigation)




        'for inquiry insert we need:
        'myClientId
        'myTypeId
        'myOwnerPerson
        Dim myComments As String = request.InquiryCreateRecord.comments

        'for inquiry_work insert we need:
        '

        'for inquiry_workinprogress insert we need:
        Dim mySavename As String = request.InquiryCreateRecord.title
        'myUid

        'for externalWipDetails insert we need:
        Dim myExt_clientpty_id As String = request.InquiryCreateRecord.ext_clientpty_id
        Dim myExt_clientpty_name As String = request.InquiryCreateRecord.ext_clientpty_id
        Dim myExt_user_id As String = request.InquiryCreateRecord.ext_user_id
        Dim myExt_user_name As String = request.InquiryCreateRecord.ext_user_name
        Dim myExt_user_email As String = request.InquiryCreateRecord.email
        Dim myExt_user_phone As String = request.InquiryCreateRecord.phone_nr




        Try
            response = access.InquiryCreateRequestData(myClientId, myTypeId, myOwnerPerson, myComments, mySavename, myUid, myExt_clientpty_id, myExt_clientpty_name, myExt_user_id, myExt_user_name, myExt_user_email, myExt_user_phone)
            response.ResponseRecordAttributes.sysmessage = "success"
            response.ResponseRecordAttributes.responseAction = "InquiryCreate"
        Catch ex As Exception
            response.ResponseRecordAttributes.systype = "fail"
            If Not response.ResponseRecordAttributes.sysmessage = "" Then
                'this should capture message from dataClass, if not then
                response.ResponseRecordAttributes.sysmessage = ex.Message
            End If
            response.ResponseRecordAttributes.responseAction = "InquiryCreate"
        End Try

        Return response
    End Function
-------------------------------------
the dataAccess just executes SP's and returns the values


This all went pretty much straight forward ...
I just can't for the life of me get the consumer up. It's mostly my inexperience on a really basic level.

I just really need to push a static request into the webservice - example:
        request.InquiryCreateRecord.category = "Accounts"
        request.InquiryCreateRecord.type = "Entries"
        request.InquiryCreateRecord.title = "help with problem"
        request.InquiryCreateRecord.comments = "this is my question"
        request.InquiryCreateRecord.email = "me@this.com"
        request.InquiryCreateRecord.phone_nr = "+46 22 123 348"
        request.InquiryCreateRecord.ext_clientpty_id = "12341234123412"
        request.InquiryCreateRecord.ext_clientpty_name = "Client Industries"
        request.InquiryCreateRecord.ext_user_id = "x12345"
        request.InquiryCreateRecord.ext_user_name = "Peter ClientMan"
        request.InquiryCreateRecord.country = "SE"


.... thanx for the help :)
Let's review:

1) Create an instance of the web service proxy.

    Example:
    Dim weatherService As New WeatherStation.WeatherService

2) Create an instance of a class

    Example:
    Dim forecastRequest As New ForecastRequest
    forecastRequest.ZipCode = "31509"
   
3) Call a web method and get a response

    Example:
    Dim forecastResult As ForecastResult = weatherService.GetForecastForZipCode(forecastRequest)
thanx,

on no. 2
ln1- Dim forecastRequest As New ForecastRequest
ln2- forecastRequest.ZipCode = "31509"

I get a
Object reference not set to an instance of an object. on ln2
even though it's instanciated with new on ln1 ..
??
If line 1 didn't work, then there was a problem with the constructor.  That doesn't sound good.  This sounds like a good place to use debugging.  

If you place a break point on this line in the IDE:

 Dim request As New localhostQtsService.RetrieveInquiryCreateRequestRequest

you should be able to step into the constructor for RetrieveInquiryCreateRequestRequest.
Imports WebApplication7_testServ.qtsserv

Partial Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim myRequest As New qtsserv.RetrieveIndividualUpdateListRequest
        myRequest.IndividualUpdateListRecord.ext_clientpty_id = "55670003270004"
        myRequest.IndividualUpdateListRecord.ext_user_id = "x12121"
        myRequest.IndividualUpdateListRecord.from_date = "2009-12-01 00:01:00"
        myRequest.IndividualUpdateListRecord.to_date = "2009-12-31 23:59:00"

        Dim myService As New QtsService
        myService.RetrieveIndividualUpdateList(myRequest)

-> the attached pic is the prntscrn from vs ..
- well - I can't get a good pic with the intellisense visible - but for myRequest it says
IndividualUpdateListRecord         | Nothing
IndividualUpdateListRecordField  | Nothing
RequestRecordAttributes            | Nothing
RequestRecordAttributesField     | Nothing
How is IndividualUpdateListRecord supposed to be set? Is it set in a web method call, or is it set from the proxy code that is generated? I have attached a screen image and code that explains what I mean by "proxy" class.
'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:2.0.50727.3082
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On

Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization

'
'This source code was auto-generated by Microsoft.VSDesigner, Version 2.0.50727.3082.
'
Namespace Weather
    
    '''<remarks/>
    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053"),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Web.Services.WebServiceBindingAttribute(Name:="WeatherSoap", [Namespace]:="http://ws.cdyne.com/WeatherWS/")>  _
    Partial Public Class Weather
        Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
        
        Private GetWeatherInformationOperationCompleted As System.Threading.SendOrPostCallback
        
        Private GetCityForecastByZIPOperationCompleted As System.Threading.SendOrPostCallback
        
        Private GetCityWeatherByZIPOperationCompleted As System.Threading.SendOrPostCallback
        
        Private useDefaultCredentialsSetExplicitly As Boolean
        
        '''<remarks/>
        Public Sub New()
            MyBase.New
            Me.Url = Global.WindowsApplication2.My.MySettings.Default.WindowsApplication2_Weather_Weather
            If (Me.IsLocalFileSystemWebService(Me.Url) = true) Then
                Me.UseDefaultCredentials = true
                Me.useDefaultCredentialsSetExplicitly = false
            Else
                Me.useDefaultCredentialsSetExplicitly = true
            End If
        End Sub

Open in new window

Screenshot.png
Thank you!

I usually do show all files - but I never opened the .map and I never knew the reference.vb was the proxy class.

I've attached the ref file.
If i understand correctly it is set in the proxy class ..yes ? (as it should be)


by some stroke of ambition I tried:
        Dim myRequest As New qtsserv.RetrieveIndividualUpdateListRequest
        Dim myrequestrecord As New qtsserv.RetrieveIndividualUpdateListRequestIndividualUpdateListRecord

        myrequestrecord.ext_clientpty_id = "55670003270004"
        myrequestrecord.ext_user_id = "x12121"
        myrequestrecord.from_date = "2009-12-01 00:01:00"
        myrequestrecord.to_date = "2009-12-31 23:59:00"

        Dim myService As New QtsService
        myService.PreAuthenticate = True
        myService.Credentials = System.Net.CredentialCache.DefaultCredentials

        myService.RetrieveIndividualUpdateList(myRequest)


I can finally step into the debugging now - but I can't connect myrequestrecord to myRequest - so I can't send my values in ..

Reference.vb
From the proxy class, here is the answer to my question above:

'''<remarks/>
    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3082"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true, [Namespace]:="http://qts.sebank.se/services/")>  _
    Partial Public Class RetrieveIndividualUpdateListRequest
       
        Private requestRecordAttributesField As RetrieveIndividualUpdateListRequestRequestRecordAttributes
       
        Private individualUpdateListRecordField As RetrieveIndividualUpdateListRequestIndividualUpdateListRecord
       
        '''<remarks/>
        Public Property RequestRecordAttributes() As RetrieveIndividualUpdateListRequestRequestRecordAttributes
            Get
                Return Me.requestRecordAttributesField
            End Get
            Set
                Me.requestRecordAttributesField = value
            End Set
        End Property
       
        '''<remarks/>
        Public Property IndividualUpdateListRecord() As RetrieveIndividualUpdateListRequestIndividualUpdateListRecord
            Get
                Return Me.individualUpdateListRecordField
            End Get
            Set
                Me.individualUpdateListRecordField = value
            End Set
        End Property
    End Class

You can see where the field and the property were created by the proxy generator, but nothing that constructs a new instance for those fields.  You will need to create a new instance of those in your code.

 Dim myRequest As New qtsserv.RetrieveIndividualUpdateListRequest
 myRequest.IndividualUpdateListRecord = New IndividualUpdateListRecord()
...
I think that's what I did here:
Dim myRequest As New qtsserv.RetrieveIndividualUpdateListRequest
        Dim myrequestrecord As New qtsserv.RetrieveIndividualUpdateListRequestIndividualUpdateListRecord

in your ex - for New IndividualUpdateListRecord() I get a 'type undefined'


the combination of the two would be
Dim myRequest As New qtsserv.RetrieveIndividualUpdateListRequest
        Dim myrequestrecord As New qtsserv.RetrieveIndividualUpdateListRequestIndividualUpdateListRecord
        myRequest.IndividualUpdateListRecord = myrequestrecord

I have to leave for a meeting. I'll have to pick this up afterwards. Thanks so much for your time!
Yeah, I didn't get the right type (Monday morning blues)...

Dim myRequest As New qtsserv.RetrieveIndividualUpdateListRequest
myRequest.IndividualUpdateListRecord = New RetrieveIndividualUpdateListRequestIndividualUpdateListRecord()
Thanx man! I appreciate your help!

All is moving forward relatively smoothly now ... all methods are debugged.
-> Except <- oddly enough -> the same problem I had when I started this question ...

object mgt and iteration throught enumerated object ...
the earlier post ( 30/12/09 10:25 AM, ID: 26144094 )
I changed the code to this:

        Try
            dr = MyCommand.ExecuteReader()
            Dim i As Integer = 0
            While dr.Read
                responseItem = New IndividualUpdateListResponseIndividualUpdateListResponseItem
                responseItem.qts_incident_id = dr(0)
                responseItem.qts_message_id = dr(1)
                responseItem.title = dr(2)
                responseItem.log_date = dr(3)
                'responseItem.direction = dr(4)
                'responseItem.isOriginal = dr(5)
                If dr(4) = "fromExtApp" Then
                    responseItem.direction = direction.fromExtApp
                Else
                    responseItem.direction = direction.toExtApp
                End If
                If dr(5) = "yes" Then
                    responseItem.isOriginal = isOriginal.yes
                Else
                    responseItem.isOriginal = isOriginal.no
                End If
                response.IndividualUpdateListResponseItem(i) = responseItem
                i = i + 1
            End While
            'attributes are set in businessLogic
            dr.Close()
        Catch ex As Exception
            response.ResponseRecordAttributes.systype = "fail"
            response.ResponseRecordAttributes.sysmessage = "cannot perform list query. " & ex.Message
            response.ResponseRecordAttributes.responseAction = "IndividualUpdateList"
            dr.Close()
        End Try

I figure I have to instantiate my responseItem inside the while loop (a new item per row)
but - when I try to build my object response.IndividualUpdateListResponseItem(i) = responseItem

I get object ref not set ..?
don't suppose you have any ideas?
I believe that problem is related to the fix that I showed you before, since the proxy generator doesn't include any code to instantiate the objects.  Any time that you get that exception, you need to look at which objects you are trying to reference, and how they are supposed to be constructed.  When there is any New construction for an object in the proxy class, then you need to handle that in your code.
right  - but as far as I can tell all objects for this response are instantiated ...

the shorthand of it looks like this  ...

        Dim response As New IndividualUpdateListResponse
        Dim responseItem As IndividualUpdateListResponseIndividualUpdateListResponseItem
        ...
        Try
            dr = MyCommand.ExecuteReader()
            Dim i As Integer = 0
            While dr.Read
                responseItem = New IndividualUpdateListResponseIndividualUpdateListResponseItem
                responseItem.qts_incident_id = dr(0)
                ...
                response.IndividualUpdateListResponseItem(i) = responseItem
                i = i + 1
            End While
            dr.Close()
        ...
        End Try

as far as i can tell there are no other objects for this response ... ?
OK, what line are you getting that error on?
response.IndividualUpdateListResponseItem(i) = responseItem
Does the IndividualUpdateListResponseItem array have a size?
minOccurs=0
maxOccurs=unbounded

<System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038"), _
 System.SerializableAttribute(), _
 System.Diagnostics.DebuggerStepThroughAttribute(), _
 System.ComponentModel.DesignerCategoryAttribute("code"), _
 System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=True, [Namespace]:="http://qts.sebank.se/services/"), _
 System.Xml.Serialization.XmlRootAttribute([Namespace]:="http://qts.sebank.se/services/", IsNullable:=False)> _
Partial Public Class IndividualUpdateListResponse

    Private responseRecordAttributesField As ResponseRecordAttributes

    Private individualUpdateListResponseItemField() As IndividualUpdateListResponseIndividualUpdateListResponseItem

    '''<remarks/>
    Public Property ResponseRecordAttributes() As ResponseRecordAttributes
        Get
            Return Me.responseRecordAttributesField
        End Get
        Set(ByVal value As ResponseRecordAttributes)
            Me.responseRecordAttributesField = value
        End Set
    End Property

    '''<remarks/>
    <System.Xml.Serialization.XmlElementAttribute("IndividualUpdateListResponseItem")> _
    Public Property IndividualUpdateListResponseItem() As IndividualUpdateListResponseIndividualUpdateListResponseItem()
        Get
            Return Me.individualUpdateListResponseItemField
        End Get
        Set(ByVal value As IndividualUpdateListResponseIndividualUpdateListResponseItem())
            Me.individualUpdateListResponseItemField = value
        End Set
    End Property
End Class

'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038"), _
 System.SerializableAttribute(), _
 System.Diagnostics.DebuggerStepThroughAttribute(), _
 System.ComponentModel.DesignerCategoryAttribute("code"), _
 System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=True, [Namespace]:="http://qts.sebank.se/services/")> _
Partial Public Class IndividualUpdateListResponseIndividualUpdateListResponseItem

    Private qts_incident_idField As String

    Private qts_message_idField As String

    Private titleField As String

    Private log_dateField As String

    Private isOriginalField As isOriginal

    Private directionField As direction

    '''<remarks/>
    Public Property qts_incident_id() As String
        Get
            Return Me.qts_incident_idField
        End Get
        Set(ByVal value As String)
            Me.qts_incident_idField = value
        End Set
    End Property

Open in new window

The minOccurs and maxOccurs are only in the .xsd schema to define validity, not to create a size.  

You need something like this:

Redim response.IndividualUpdateListResponseItem(10)
hmmm so -
i need to :
dim and instance the response
dim item
count the rows in the datareader result
redim the item(to rowcount -1)
run the while loop
instance item(i)
assign vals
increment i
next

does that sound right?
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've never 'Redim Preserve' 'd  before ... I'll have to check that out

i primitively managed the below

... hmm ... didn't realize you can't get a rowcout from a datareader ... huh and recordsaffected is invalid as a row count
Try
            dr = MyCommand.ExecuteReader()
            Dim i As Integer = 0
            While dr.Read
                i = i + 1
            End While
            dr.Close()

            ReDim response.IndividualUpdateListResponseItem(i)

            dr = MyCommand.ExecuteReader()
            i = 0
            While dr.Read
                responseItem = New IndividualUpdateListResponseIndividualUpdateListResponseItem
                ...
                response.IndividualUpdateListResponseItem(i) = responseItem
                i = i + 1
            End While
        ...
        dr.Close()
        End Try

Open in new window

on the consumer test side I'm running

Dim myResponse As New qtsServLocal.RetrieveIndividualUpdateListResponseRetrieveIndividualUpdateListResult
        myResponse = myService.RetrieveIndividualUpdateList(myRequest)

you don't happen to know how to tostring the response xml?
OK, let's take a step back, and look at what you have...

If you think that you need a record count, it would be better to use a data adapter, instead of opening the data reader twice.

Example:


Dim tableProduct As New DataTable()
Dim connectionString As String = ConfigurationManager.ConnectionStrings("AdventureWorks").ConnectionString
Using adapter As New SqlDataAdapter("Select * From Production.Product", connectionString)
    adapter.Fill(tableProduct)
End Using
Dim recordCount As Integer = tableProduct.Rows.Count

Open in new window

If you open a web browser, and navigate to the URL for the web service, you should get a test page, where you can test the web method, and see the XML response.
you're entirely correct. i completely forgot about the adapter. (It's been a long time since I've been actively programming ... the adapter would be much more manageable, I can also sort it before sending - I was about to modify the sp to order the select ...
If you have a stored procedure, remember that you need to change the CommandType for the adapter:


Using adapter As New SqlDataAdapter("spGetProducts", connectionString) 
   adapter.SelectCommand.CommandType = CommandType.StoredProcedure

...

Open in new window

i don't get any test capabilities - only xml examples for soap 1.1 and 1.2 for the webmethods

i want to write the response xml in string format from the actual queries - to a textbox for example.
then I actually see the xml ...
thanx for the reminder !!

you really deserve more points than I can give - apparently 500 is the maximum?
(I'm real new to expExch)
I can't define my own point value?

I guess I can open new questions if you'd like :)

another party is developing the actual consumer and they just told me that they can't use soap1.2. My wsdl has bindings and port types for both versions - how can I steer the version of soap my response sends ? or does the engine manage it all for me / us)
1) I have been doing this EE stuff for 10+ years, and it was never about the points, but more about teaching, and learning.

2) I believe that getting the SOAP response, while possible, is certainly beyond the scope of this question.
thanx man!
you have been too good to me.
In all honesty - I'm happy no one replied at first, because this got 'auto-alerted' and I got you :)

seriously though - you got me through a hard time - thanx!
Excellent Help !!