VB.NET Web Services question

VB.NET Web Services question

Page 1 of 1

2 Replies - 1660 Views - Last Post: 18 July 2007 - 06:23 PM Rate Topic: -----

#1 subratparida  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 17-July 07

VB.NET Web Services question

Posted 17 July 2007 - 05:36 PM

Hi,

I am calling a web services in VB.NET. The code is almost done but I am getting an error at shipping section that I don't know how to fix. I think it is very simple but I don't know how to figure it out.

Error is “Too many arguments to ‘Public Sub New()’ at value 1” at this line “Shipment.ShipmentItems = New ShipmentItem(1)”. I am not still sure that this is the right way of calling shipment class because shipment is a sub-class of salesorder.

----------------------------------------------------------------
Dim aToken As UsernameToken = New UsernameToken("test@abc.com", "test123", PasswordOption.SendPlainText)
mSalesOrderWse = New SalesOrderService
mSalesOrderWse.RequestSoapContext.Security.Timestamp.TtlInSeconds = 30
mSalesOrderWse.RequestSoapContext.Security.Tokens.Add(aToken)

Dim OrderRequest As New CheckComplianceOfSalesOrderRequest

OrderRequest.AddressOption = New SalesOrder.AddressOption
OrderRequest.AddressOption.IgnoreStreetLevelErrors = "True"
OrderRequest.AddressOption.RejectIfAddressSuggested = "True"

OrderRequest.PersistOption = PersistOption.Null

OrderRequest.SalesOrder = New SalesOrder.SalesOrder
OrderRequest.SalesOrder.BillTo = New SalesOrder.Address
OrderRequest.SalesOrder.BillTo.City = ocity
OrderRequest.SalesOrder.BillTo.Company = ocompany
OrderRequest.SalesOrder.BillTo.Country = ocountry
OrderRequest.SalesOrder.BillTo.County = ""
OrderRequest.SalesOrder.BillTo.Email = oemail
OrderRequest.SalesOrder.BillTo.Fax = ""
OrderRequest.SalesOrder.BillTo.FirstName = ofirstname
OrderRequest.SalesOrder.BillTo.LastName = olastname
OrderRequest.SalesOrder.BillTo.Phone = ophone
OrderRequest.SalesOrder.BillTo.State = ostate
OrderRequest.SalesOrder.BillTo.Street1 = oaddress
OrderRequest.SalesOrder.BillTo.Street2 = oaddress2
OrderRequest.SalesOrder.BillTo.Zip1 = opostcode
OrderRequest.SalesOrder.BillTo.Zip2 = ""

OrderRequest.SalesOrder.CustomerKey = custnmbr
OrderRequest.SalesOrder.FulfillmentType = FulfillmentType.Null
OrderRequest.SalesOrder.OrderType = OrderType.Internet
OrderRequest.SalesOrder.PurchaseDate = odate
OrderRequest.SalesOrder.SalesOrderKey = sopnumbe

Dim ShipmentItem2 As New ShipmentItem

ShipmentItem2.BrandKey = "SS_WINE"
ShipmentItem2.ProductKey = "04SSBOTELLA750"
ShipmentItem2.ProductQuantity = 1
ShipmentItem2.ProductUnitPrice = 20

Dim Shipment As New Shipment
Shipment.Freight = oshipcost
Shipment.LicenseRelationship = LicenseRelationship.SupplierToConsumer
Shipment.ShipDate = deliverydate
Shipment.ShipmentKey = "1"
Shipment.ShipmentStatus = ShipmentStatus.PaymentAccepted
Shipment.ShippingService = ShippingService.FXG
Shipment.InsuredAmount = 0
Shipment.GiftNote = ""
Shipment.SpecialInstructions = ocomment

Shipment.ShipTo = New Address
Shipment.ShipTo.Company = oshipcompany
Shipment.ShipTo.FirstName = oshipFName
Shipment.ShipTo.LastName = oshipLName
Shipment.ShipTo.City = oshiptown
Shipment.ShipTo.State = oshipstate
Shipment.ShipTo.Street1 = oshipaddress
Shipment.ShipTo.Street2 = oshipaddress2
Shipment.ShipTo.Country = oshipcountry
Shipment.ShipTo.Zip1 = oshipzip
Shipment.ShipTo.Zip2 = ""
Shipment.ShipTo.Fax = ""
Shipment.ShipTo.Phone = ship_phone
Shipment.ShipTo.Email = oemail
Shipment.ShipTo.County = ""

Shipment.ShipmentItems = New ShipmentItem(1)
Shipment.ShipmentItems(0) = ShipmentItem2

OrderRequest.SalesOrder.Shipments = New Shipment(1)
OrderRequest.SalesOrder.Shipments(0) = Shipment

OrderResponse = mSalesOrderWse.CheckComplianceOfSalesOrder(OrderRequest)


-----------------------------------------------

This secure class code was autometically generated.

Public Class SalesOrder
Public BillTo As Address
Public CustomerKey As String
Public FulfillmentType As FulfillmentType
Public OrderType As OrderType
Public PurchaseDate As Date
Public SalesOrderKey As String
Public Shipments() As Shipment
End Class

_
Public Class Address
Public City As String
Public Company As String
Public Country As String
Public County As String
Public DateOfBirth As Date
Public Email As String
Public Fax As String
Public FirstName As String
Public LastName As String
Public Phone As String
Public State As String
Public Street1 As String
Public Street2 As String
Public Zip1 As String
Public Zip2 As String
End Class

_
Public Class Shipment
Public Freight As Double
Public GiftNote As String
Public InsuredAmount As Double
Public LicenseRelationship As LicenseRelationship
Public Packages() As Package
Public ShipDate As Date
Public ShipmentItems() As ShipmentItem
Public ShipmentKey As String
Public ShipmentStatus As ShipmentStatus
Public ShippingService As ShippingService
Public ShipTo As Address
Public SpecialInstructions As String
End Class

_
Public Class ShipmentItem
Public BrandKey As String
Public ProductKey As String
Public ProductQuantity As Integer
Public ProductUnitPrice As Double
End Class


----------------------------------------------

Thanks,
Subrat Parida
Programmer

Is This A Good Question/Topic? 0
  • +

Replies To: VB.NET Web Services question

#2 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: VB.NET Web Services question

Posted 18 July 2007 - 04:18 PM

First i like to ask, "do you know, that you can use with statment and you can declare a class with subclasses?".

Anyhow, error

Quote

Error is “Too many arguments to ‘Public Sub New()’ at value 1” at this line “Shipment.ShipmentItems = New ShipmentItem(1)”


means that you are not using allocated memory for the second array member of type ShipmentItem, but giving a class constructor an constant argument 1 of a type variant (or integer for that matter).

Simplest example i could think of, that would do the same without an error
Module Module1

	Sub Main()
		Dim a As ok = New ok(1)

		Console.WriteLine(a.myvalue)
		Console.ReadLine()
	End Sub

End Module
Class ok

	Public Sub New()
		_myvalue = 0
	End Sub

	Public Sub New(ByVal value As Integer)
		Me._myvalue = value
	End Sub

	Private _myvalue As Integer
	Public Property myvalue() As Integer
		Get
			Return _myvalue
		End Get
		Set(ByVal value As Integer)
			_myvalue = value
		End Set
	End Property

End Class


Note that it will print 1 in console, not 0.

The problem in your case is, that there is no
Public Sub New(ByVal value As Integer)
		Me._myvalue = value
	End Sub


like over loader for the class constructor, or you are passing the wrong type(!). Reminder: you can use converter like ctype(1,byte) to specify correct argument type.


Hope it helped. :D
Was This Post Helpful? 0
  • +
  • -

#3 subratparida  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 17-July 07

Re: VB.NET Web Services question

Posted 18 July 2007 - 06:23 PM

Thank you for looking at this issue.

This issue has been fixed.

Thanks,
Subrat

View Postm2s87, on 18 Jul, 2007 - 04:18 PM, said:

First i like to ask, "do you know, that you can use with statment and you can declare a class with subclasses?".

Anyhow, error

Quote

Error is “Too many arguments to ‘Public Sub New()’ at value 1” at this line “Shipment.ShipmentItems = New ShipmentItem(1)”


means that you are not using allocated memory for the second array member of type ShipmentItem, but giving a class constructor an constant argument 1 of a type variant (or integer for that matter).

Simplest example i could think of, that would do the same without an error
Module Module1

	Sub Main()
		Dim a As ok = New ok(1)

		Console.WriteLine(a.myvalue)
		Console.ReadLine()
	End Sub

End Module
Class ok

	Public Sub New()
		_myvalue = 0
	End Sub

	Public Sub New(ByVal value As Integer)
		Me._myvalue = value
	End Sub

	Private _myvalue As Integer
	Public Property myvalue() As Integer
		Get
			Return _myvalue
		End Get
		Set(ByVal value As Integer)
			_myvalue = value
		End Set
	End Property

End Class


Note that it will print 1 in console, not 0.

The problem in your case is, that there is no
Public Sub New(ByVal value As Integer)
		Me._myvalue = value
	End Sub


like over loader for the class constructor, or you are passing the wrong type(!). Reminder: you can use converter like ctype(1,byte) to specify correct argument type.


Hope it helped. :D

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1