I am facing hard time with this webservice. Now what I have done so far,
I
have created and XSD Schema for the XML file using XSD.exe and then
generated a call file to be used in my webservice. This is working
fine. On the test client side I have generated a proxy class and now
when I am trying to pass the XML as strongly types class I can pass the
basic parameters right but facing difficulties in the array.
The structure of XML is as follows:
.ExternalClass
{font:x-small 'Verdana';margin-right:1.5em;}
.ExternalClass .EC_c
{cursor:hand;}
.ExternalClass .EC_b
{color:red;font-family:'Courier New';font-weight:bold;text-decoration:none;}
.ExternalClass .EC_e
{margin-left:1em;text-indent:-1em;margin-right:1em;}
.ExternalClass .EC_k
{margin-left:1em;text-indent:-1em;margin-right:1em;}
.ExternalClass .EC_t
{color:#990000;}
.ExternalClass .EC_xt
{color:#990099;}
.ExternalClass .EC_ns
{color:red;}
.ExternalClass .EC_dt
{color:green;}
.ExternalClass .EC_m
{color:blue;}
.ExternalClass .EC_tx
{font-weight:bold;}
.ExternalClass .EC_db
{text-indent:0px;margin-left:1em;margin-bottom:0px;padding-left:.3em;border-left:1px solid #CCCCCC;font:small Courier;}
.ExternalClass .EC_di
{font:small Courier;}
.ExternalClass .EC_d
{color:blue;}
.ExternalClass .EC_pi
{color:blue;}
.ExternalClass .EC_cb
{text-indent:0px;margin-left:1em;margin-bottom:0px;padding-left:.3em;font:small Courier;color:#888888;}
.ExternalClass .EC_ci
{font:small Courier;color:#888888;}
.ExternalClass PRE
{display:inline;}
<?xml
version="1.0" encoding="UTF-8" ?>
- <ns0:ZHR_SAP_CHANGES_TO_LDAP xmlns:ns0="urn:sap-com:document:sap:rfc:functions">
<FIRST_NAME>AAAA</FIRST_NAME>
</item>
<FIRST_NAME>BBBBB</FIRST_NAME>
</item>
<FIRST_NAME>CCCCCC</FIRST_NAME>
</item>
<FIRST_NAME>DDDDDD</FIRST_NAME>
</item>
<FIRST_NAME>EEEEEEE</FIRST_NAME>
</item>
</USERDETAILS>
</ns0:ZHR_SAP_CHANGES_TO_LDAP>
This is my proxy class:
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:2.0.50727.1433
'
' 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 wsdl, Version=2.0.50727.1432.
'
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432"), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Web.Services.WebServiceBindingAttribute(Name:="ServiceSoap", [Namespace]:="http://www.abc.com/webservices")> _
Partial Public Class Service
Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
Private ManageUser3OperationCompleted As System.Threading.SendOrPostCallback
Private ManageUsersOperationCompleted As System.Threading.SendOrPostCallback
'''<remarks/>
Public Sub New()
MyBase.New
Me.Url = "http://10.200.219.167/webservices/service.asmx"
End Sub
'''<remarks/>
Public Event ManageUser3Completed As ManageUser3CompletedEventHandler
'''<remarks/>
Public Event ManageUsersCompleted As ManageUsersCompletedEventHandler
'''<remarks/>
<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.abc.com/webservices/ManageUser3",
RequestNamespace:="http://www.abc.com/webservices",
ResponseNamespace:="http://www.petrorabigh.com/webservices",
Use:=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
_
Public Function ManageUser3(ByVal F_Name As String, ByVal
L_Name As String, ByVal Initial As String, ByVal User_ID As String,
ByVal Email As String, ByVal Org_Code As String, ByVal Company As
String, ByVal Dept As String, ByVal Job_Title As String, ByVal Badge_No
As String, ByVal flag As String, ByVal acct_status As String, ByVal
Auth_Key As String) As ReturnValues
Dim results() As Object
= Me.Invoke("ManageUser3", New Object() {F_Name, L_Name, Initial,
User_ID, Email, Org_Code, Company, Dept, Job_Title, Badge_No, flag,
acct_status, Auth_Key})
Return CType(results(0),ReturnValues)
End Function
'''<remarks/>
Public Function BeginManageUser3(ByVal F_Name As String, ByVal L_Name
As String, ByVal Initial As String, ByVal User_ID As String, ByVal
Email As String, ByVal Org_Code As String, ByVal Company As String,
ByVal Dept As String, ByVal Job_Title As String, ByVal Badge_No As
String, ByVal flag As String, ByVal acct_status As String, ByVal
Auth_Key As String, ByVal callback As System.AsyncCallback, ByVal
asyncState As Object) As System.IAsyncResult
Return
Me.BeginInvoke("ManageUser3", New Object() {F_Name, L_Name, Initial,
User_ID, Email, Org_Code, Company, Dept, Job_Title, Badge_No, flag,
acct_status, Auth_Key}, callback, asyncState)
End Function
'''<remarks/>
Public Function EndManageUser3(ByVal asyncResult As System.IAsyncResult) As ReturnValues
Dim results() As Object = Me.EndInvoke(asyncResult)
Return CType(results(0),ReturnValues)
End Function
'''<remarks/>
Public Overloads Sub ManageUser3Async(ByVal F_Name As String, ByVal
L_Name As String, ByVal Initial As String, ByVal User_ID As String,
ByVal Email As String, ByVal Org_Code As String, ByVal Company As
String, ByVal Dept As String, ByVal Job_Title As String, ByVal Badge_No
As String, ByVal flag As String, ByVal acct_status As String, ByVal
Auth_Key As String)
Me.ManageUser3Async(F_Name, L_Name,
Initial, User_ID, Email, Org_Code, Company, Dept, Job_Title, Badge_No,
flag, acct_status, Auth_Key, Nothing)
End Sub
'''<remarks/>
Public Overloads Sub ManageUser3Async(ByVal F_Name As String, ByVal
L_Name As String, ByVal Initial As String, ByVal User_ID As String,
ByVal Email As String, ByVal Org_Code As String, ByVal Company As
String, ByVal Dept As String, ByVal Job_Title As String, ByVal Badge_No
As String, ByVal flag As String, ByVal acct_status As String, ByVal
Auth_Key As String, ByVal userState As Object)
If (Me.ManageUser3OperationCompleted Is Nothing) Then
Me.ManageUser3OperationCompleted = AddressOf Me.OnManageUser3OperationCompleted
End If
Me.InvokeAsync("ManageUser3", New Object() {F_Name, L_Name, Initial,
User_ID, Email, Org_Code, Company, Dept, Job_Title, Badge_No, flag,
acct_status, Auth_Key}, Me.ManageUser3OperationCompleted, userState)
End Sub
Private Sub OnManageUser3OperationCompleted(ByVal arg As Object)
If (Not (Me.ManageUser3CompletedEvent) Is Nothing) Then
Dim invokeArgs As
System.Web.Services.Protocols.InvokeCompletedEventArgs =
CType(arg,System.Web.Services.Protocols.InvokeCompletedEventArgs)
RaiseEvent ManageUser3Completed(Me, New
ManageUser3CompletedEventArgs(invokeArgs.Results, invokeArgs.Error,
invokeArgs.Cancelled, invokeArgs.UserState))
End If
End Sub
'''<remarks/>
<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.petrorabigh.com/webservices/ManageUsers",
RequestNamespace:="http://www.petrorabigh.com/webservices",
ResponseNamespace:="http://www.petrorabigh.com/webservices",
Use:=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
_
Public Function
ManageUsers(<System.Xml.Serialization.XmlElementAttribute([Namespace]:="urn:sap-com:document:sap:rfc:functions")>
ByVal input As input) As String
Dim results() As Object = Me.Invoke("ManageUsers", New Object() {input})
Return CType(results(0),String)
End Function
'''<remarks/>
Public Function BeginManageUsers(ByVal input As input, ByVal callback
As System.AsyncCallback, ByVal asyncState As Object) As
System.IAsyncResult
Return Me.BeginInvoke("ManageUsers", New Object() {input}, callback, asyncState)
End Function
'''<remarks/>
Public Function EndManageUsers(ByVal asyncResult As System.IAsyncResult) As String
Dim results() As Object = Me.EndInvoke(asyncResult)
Return CType(results(0),String)
End Function
'''<remarks/>
Public Overloads Sub ManageUsersAsync(ByVal input As input)
Me.ManageUsersAsync(input, Nothing)
End Sub
'''<remarks/>
Public Overloads Sub ManageUsersAsync(ByVal input As input, ByVal userState As Object)
If (Me.ManageUsersOperationCompleted Is Nothing) Then
Me.ManageUsersOperationCompleted = AddressOf Me.OnManageUsersOperationCompleted
End If
Me.InvokeAsync("ManageUsers", New Object() {input}, Me.ManageUsersOperationCompleted, userState)
End Sub
Private Sub OnManageUsersOperationCompleted(ByVal arg As Object)
If (Not (Me.ManageUsersCompletedEvent) Is Nothing) Then
Dim invokeArgs As
System.Web.Services.Protocols.InvokeCompletedEventArgs =
CType(arg,System.Web.Services.Protocols.InvokeCompletedEventArgs)
RaiseEvent ManageUsersCompleted(Me, New
ManageUsersCompletedEventArgs(invokeArgs.Results, invokeArgs.Error,
invokeArgs.Cancelled, invokeArgs.UserState))
End If
End Sub
'''<remarks/>
Public Shadows Sub CancelAsync(ByVal userState As Object)
MyBase.CancelAsync(userState)
End Sub
End Class
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://www.petrorabigh.com/webservices")> _
Partial Public Class ReturnValues
Private statusField As String
Private badge_noField As String
Private reasonField As String
'''<remarks/>
Public Property status() As String
Get
Return Me.statusField
End Get
Set
Me.statusField = value
End Set
End Property
'''<remarks/>
Public Property badge_no() As String
Get
Return Me.badge_noField
End Get
Set
Me.badge_noField = value
End Set
End Property
'''<remarks/>
Public Property reason() As String
Get
Return Me.reasonField
End Get
Set
Me.reasonField = value
End Set
End Property
End Class
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true, [Namespace]:="urn:sap-com:document:sap:rfc:functions")> _
Partial Public Class input
Private i_DATEField As String
Private uSERDETAILSField() As ArrayOfZHR_SAP_CHANGES_TO_LDAPItemItem
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property I_DATE() As String
Get
Return Me.i_DATEField
End Get
Set
Me.i_DATEField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlArrayAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified), _
System.Xml.Serialization.XmlArrayItemAttribute("item",
Form:=System.Xml.Schema.XmlSchemaForm.Unqualified,
IsNullable:=false)> _
Public Property USERDETAILS() As ArrayOfZHR_SAP_CHANGES_TO_LDAPItemItem()
Get
Return Me.uSERDETAILSField
End Get
Set
Me.uSERDETAILSField = value
End Set
End Property
End Class
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true, [Namespace]:="urn:sap-com:document:sap:rfc:functions")> _
Partial Public Class ArrayOfZHR_SAP_CHANGES_TO_LDAPItemItem
Private fIRST_NAMEField As String
Private lAST_NAMEField As String
Private iNITIALField As String
Private uSERIDField As String
Private eMAILField As String
Private oRGCODEField As String
Private pOSITIONField As String
Private dEPARTMENTField As String
Private bADGEField As String
Private fLAGField As String
Private aCCT_STATUSField As String
Private aUTH_KEYField As String
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property FIRST_NAME() As String
Get
Return Me.fIRST_NAMEField
End Get
Set
Me.fIRST_NAMEField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property LAST_NAME() As String
Get
Return Me.lAST_NAMEField
End Get
Set
Me.lAST_NAMEField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property INITIAL() As String
Get
Return Me.iNITIALField
End Get
Set
Me.iNITIALField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property USERID() As String
Get
Return Me.uSERIDField
End Get
Set
Me.uSERIDField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property EMAIL() As String
Get
Return Me.eMAILField
End Get
Set
Me.eMAILField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property ORGCODE() As String
Get
Return Me.oRGCODEField
End Get
Set
Me.oRGCODEField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property POSITION() As String
Get
Return Me.pOSITIONField
End Get
Set
Me.pOSITIONField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property DEPARTMENT() As String
Get
Return Me.dEPARTMENTField
End Get
Set
Me.dEPARTMENTField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property BADGE() As String
Get
Return Me.bADGEField
End Get
Set
Me.bADGEField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property FLAG() As String
Get
Return Me.fLAGField
End Get
Set
Me.fLAGField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property ACCT_STATUS() As String
Get
Return Me.aCCT_STATUSField
End Get
Set
Me.aCCT_STATUSField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property AUTH_KEY() As String
Get
Return Me.aUTH_KEYField
End Get
Set
Me.aUTH_KEYField = value
End Set
End Property
End Class
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")> _
Public Delegate Sub ManageUser3CompletedEventHandler(ByVal sender As Object, ByVal e As ManageUser3CompletedEventArgs)
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432"), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code")> _
Partial Public Class ManageUser3CompletedEventArgs
Inherits System.ComponentModel.AsyncCompletedEventArgs
Private results() As Object
Friend Sub New(ByVal results() As Object, ByVal exception As
System.Exception, ByVal cancelled As Boolean, ByVal userState As Object)
MyBase.New(exception, cancelled, userState)
Me.results = results
End Sub
'''<remarks/>
Public ReadOnly Property Result() As ReturnValues
Get
Me.RaiseExceptionIfNecessary
Return CType(Me.results(0),ReturnValues)
End Get
End Property
End Class
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")> _
Public Delegate Sub ManageUsersCompletedEventHandler(ByVal sender As Object, ByVal e As ManageUsersCompletedEventArgs)
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432"), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code")> _
Partial Public Class ManageUsersCompletedEventArgs
Inherits System.ComponentModel.AsyncCompletedEventArgs
Private results() As Object
Friend Sub New(ByVal results() As Object, ByVal exception As
System.Exception, ByVal cancelled As Boolean, ByVal userState As Object)
MyBase.New(exception, cancelled, userState)
Me.results = results
End Sub
'''<remarks/>
Public ReadOnly Property Result() As String
Get
Me.RaiseExceptionIfNecessary
Return CType(Me.results(0),String)
End Get
End Property
End Class
now in my test client I am doing the following and this is working fine.
Dim aaa123 As New input
aaa123.I_DATE = "10-10-2008"
Dim dd1 As New Service
MessageBox.Show(dd1.ManageUsers(aaa123))
but when I am trying to add data to the array I am getting error object reference not set to an instance of an object.
aaa123.USERDETAILS(0).FIRST_NAME = "Muhammad"
aaa123.USERDETAILS(0).LAST_NAME = "Umar"
aaa123.USERDETAILS(0).INITIAL = "Q"
aaa123.USERDETAILS(0).USERID = "umarmq"
aaa123.USERDETAILS(0).EMAIL = "umar@pr.com"
aaa123.USERDETAILS(0).ORGCODE = "1234"
aaa123.USERDETAILS(0).DEPARTMENT = "IT"
aaa123.USERDETAILS(0).BADGE = "101010"
aaa123.USERDETAILS(0).ACCT_STATUS = "A"
aaa123.USERDETAILS(0).FLAG = "I"
aaa123.USERDETAILS(0).POSITION = "CONS"
aaa123.USERDETAILS(0).FIRST_NAME = "Muhammad"
aaa123.USERDETAILS(0).LAST_NAME = "Umar"
aaa123.USERDETAILS(0).INITIAL = "Q"
aaa123.USERDETAILS(0).USERID = "umarmq"
aaa123.USERDETAILS(0).EMAIL = "umar@pr.com"
aaa123.USERDETAILS(0).ORGCODE = "1234"
aaa123.USERDETAILS(0).DEPARTMENT = "IT"
aaa123.USERDETAILS(0).BADGE = "101010"
aaa123.USERDETAILS(0).ACCT_STATUS = "A"
aaa123.USERDETAILS(0).FLAG = "I"
aaa123.USERDETAILS(0).POSITION = "CONS"
what am I doing wrong here?