PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → WebService Structures Failure
WebService Structures Failure
Iniciado por José BRANDÃO, 09,feb. 2018 16:51 - 3 respuestas
Miembro registrado
16 mensajes
Publicado el 09,febrero 2018 - 16:51
Done using Windev22

Im developing a webservice to be used by a website that will request articles informations.

I have a fixed wsdl to use (http://golfinhosoft.webdev-test.com/OMA_WEB/awws/OMA.awws…) and with it i built the following structures:

ErpAvailabilityStatus is Enumeration
unbekannt = "unbekannt"
verfuegbar = "verfuegbar"
nichtverfuegbar = "nichtverfuegbar"
teilvefuergbar = "teilvefuergbar"
alternativlagerverfuegbar = "alternativlagerverfuegbar"
nochnichtangefragt = "nochnichtangefragt"
END

GetArticleInformation is structure
User is User
Items is Items
END
GetArticleInformationResponse is structure
GetArticleInformationResult is GetBackItems
END
GetBackItems is structure
Items is Items
ErrorCode is numeric
ErrorId is numeric
ErrorMessage is string
END
ArrayOfPrice is structure
Price is array of Price
END
ArrayOfQuantity is structure
Quantity is array of Quantity
END
ArrayOfCustomer is structure
Customer is List of Customer
END
Suppliers is structure
Supplier is ArrayOfSupplier
END
ArrayOfString is structure
'string' is array of string
END
ArrayOfSupplier is structure
Supplier is List of Supplier
END
ArrayOfLocation is structure
Location is array of Location
END
Item is structure
Locations is ArrayOfLocation
Prices is ArrayOfPrice
Suppliers is Suppliers
Customers is Customers
WholesalerArtNr is string
EinspNr is string
EinspArtNr is string
RequestedQuantity is Quantity
Quantity is ArrayOfQuantity
Memo is ArrayOfString
AlternativeItems is ArrayOfItem
// AvailState is EErpAvailabilityStatus
AvailState is string
END
Items is a structure
Item is ArrayOfItem
END
ArrayOfItem is a structure
Item is array of Item
END
QuantityExtended is structure
PackingUnit is string
MinQuantity is numeric
MaxQuantity is numeric
ExpectedDeliveryTime is string
// AvailState is EErpAvailabilityStatus
AvailState is string
END
Price is structure
Text is string
Value is numeric
VAT is numeric
TaxIncluded is boolean
CurrencyCode is string
Rebate is numeric
BatchSize is Quantity
END
Location is structure
Id is string
Text is string
Quantity is ArrayOfQuantity
END
User is structure
CustomerId is string
PassWord is string
UserName is string
SID is string
END
Quantity is structure
Text is string
Value is numeric
QuantitieUnit is string
QuantityExtended is QuantityExtended
END
Customer is structure
Id is string
Text is string
END
Supplier is structure
Id is string
Text is string
END
Customers is structure
Customer is ArrayOfCustomer
END



Either using SoapUI, the test of the webservice on the website or testing with Windev, to call the function, i can do it just fine without any error of structure or variables.
The problem comes when i try to read the response from it, the "Error" fields show up but the "Items" field isnt coming back.
Here is my code inside the webservice:

Procedure GetArticleInformation(stUser is User,stItems is Items)

stGetBackItems is GetBackItems
stGetBackItems.ErrorCode = 0
stGetBackItems.ErrorId = 100
stGetBackItems.ErrorMessage = "SUCESS"

clItems is Items
clArrayOfItem is ArrayOfItem
arrArrayOfItem is array of Item
clItem is Item

clItem.WholesalerArtNr="123456789"
clItem.AvailState=verfuegbar

clArrayOfLocation is ArrayOfLocation
arrArrayOfLocation is array of Location
clLocation is Location

clArrayOfQuantity is ArrayOfQuantity
arrArrayOfQuantity is array of Quantity
clQuantity is Quantity

clQuantityExtended is QuantityExtended
clQuantityExtended.AvailState=verfuegbar

clQuantity.QuantityExtended=clQuantityExtended
clQuantity.Text="Stock"
clQuantity.QuantitieUnit="UNI"
clQuantity.Value=15
Add(arrArrayOfQuantity,clQuantity)
clArrayOfQuantity.Quantity=arrArrayOfQuantity

clLocation.Quantity=clArrayOfQuantity
clLocation.Id=1
clLocation.Text="Description of location"
Add(arrArrayOfLocation,clLocation)
clArrayOfLocation.Location=arrArrayOfLocation

clItem.Locations=clArrayOfLocation

clArrayOfPrice is ArrayOfPrice
arrArrayOfPrice is array of Price
clPrice is Price

clPrice.Text="P.V.P."
clPrice.Value=99.99
Add(arrArrayOfPrice,clPrice)
clArrayOfPrice.Price=arrArrayOfPrice

clItem.Prices=clArrayOfPrice

Add(arrArrayOfItem,clItem)
clArrayOfItem.Item=arrArrayOfItem
clItems.Item=clArrayOfItem
stGetBackItems.items=clItems

RESULT stGetBackItems



Here is the request that i send in Windev:

cGetArticleInformation is Erp.GetArticleInformation
cGetArticleInformationResponse is Erp.GetArticleInformationResponse

cGetArticleInformation.user.CustomerId="123"
cGetArticleInformation.user.UserName="123"
cGetArticleInformation.user.PassWord="123"
cGetArticleInformation.user.SID="1"

Artigo is Erp.Item

Artigo.WholesalerArtNr="123"
Artigo.EinspNr="456"
Artigo.EinspArtNr="789"
Artigo.AvailState = EErpAvailabilityStatus.nochnichtangefragt
ArrayAdd(cGetArticleInformation.items.Item.Item,Artigo)

Artigo.WholesalerArtNr="321"
Artigo.EinspNr="654"
Artigo.EinspArtNr="987"
Artigo.AvailState = EErpAvailabilityStatus.nichtverfuegbar
ArrayAdd(cGetArticleInformation.items.Item.Item,Artigo)

Artigo.WholesalerArtNr="321"
Artigo.EinspNr="654"
Artigo.EinspArtNr="987"
Artigo.AvailState = EErpAvailabilityStatus.nichtverfuegbar
ArrayAdd(cGetArticleInformation.items.Item.Item,Artigo)

cGetArticleInformationResponse=Erp.GetArticleInformation(cGetArticleInformation)



Here is the response that i get in Windev:







Here is the request that SoapUI automatically generates (i cutted it for better and easier understanding):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dvse="DVSE.WebApp.ErpService">
<soapenv:Header/>
<soapenv:Body>
<dvse:GetArticleInformation>
<dvse:user>
<dvse:CustomerId></dvse:CustomerId>
<dvse:PassWord></dvse:PassWord>
<dvse:UserName></dvse:UserName>
<dvse:SID></dvse:SID>
</dvse:user>
<dvse:items>
<dvse:Item>
<dvse:Item>
<dvse:WholesalerArtNr>123456789</dvse:WholesalerArtNr>
<dvse:EinspNr></dvse:EinspNr>
<dvse:EinspArtNr></dvse:EinspArtNr>
<dvse:AvailState>verfuegbar</dvse:AvailState>
</dvse:Item>
</dvse:Item>
</dvse:items>
</dvse:GetArticleInformation>
</soapenv:Body>
</soapenv:Envelope>



Here is the response that i get in SoapUI:

<SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns1:GetArticleInformationResponse xmlns:ns1="DVSE.WebApp.ErpService">
<ns1:GetArticleInformationResult>
<ns1:ErrorCode>0</ns1:ErrorCode>
<ns1:ErrorId>100</ns1:ErrorId>
<ns1:ErrorMessage>SUCESS</ns1:ErrorMessage>
</ns1:GetArticleInformationResult>
</ns1:GetArticleInformationResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>



So far i have found a problem that might be causing this issue:

When i "Serialize" the "stGetBackItems", instead of getting something like <GetBackItems><Items><Item><Item><WholesalerArtNr>...., im getting <GetBackItems><Items><Item><Item><Item><WholesalerArtNr> , one extra <Item>.
This is not only happening with the "<Item>" field but also with "<Location>", "<Quantity>", "<Price>", "<Supplier>" and "<Customer>". All these are the fields that are part of the "ArrayOf...." Structures.

I've also sent a technical support request but we all know what the answer is likely to be :)
Mensaje modificado, 09,febrero 2018 - 16:54
Miembro registrado
16 mensajes
Publicado el 12,febrero 2018 - 17:47
2 problems that i found meanwhile:

the first problem was the way i was receiving both variables, should be this:
Procedure GetArticleInformation(User is User,Items is Items)

instead of this:
Procedure GetArticleInformation(stUser is User,stItems is Items)


and the other problem is that when windev generates the wsdl (which im not using) it includes something like this:
<xsd:complexType name="ArrayOfCustomer" s0:nomcomplet="ArrayOfCustomer">
<xsd:sequence>
<xsd:element name="Customer" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>

while it should be:
<xsd:complexType name="ArrayOfCustomer" s0:nomcomplet="ArrayOfCustomer">
<xsd:sequence>
<xsd:element name="Customer" type="s0:Customer"/>
</xsd:sequence>
</xsd:complexType>

same for the ArrayOfSupplier

but in the end... the initial problem is still there, no luck yet
Mensaje modificado, 12,febrero 2018 - 17:48
Miembro registrado
16 mensajes
Publicado el 08,marzo 2018 - 16:40
For anyone interested in the subject or with a similar problem, this is the way i solved it:
Receiving both parameters with the structures i created manually (the ones above).
Constructed and returned the structures variables using the structures of the webservice (the said "fixed WSDL")

Example:
Procedure GetArticleInformation(User is User,Items is Items)

stGetBackItems is ImportedWebserviceName.GetBackItems
stGetBackItems.ErrorCode = 0
stGetBackItems.ErrorId = 100
stGetBackItems.ErrorMessage = "SUCCESS"

stItemOrigin is ImportedWebserviceName.Item

FOR EACH stItemOrigem OF Items.Item.Item
stItems is ImportedWebserviceName.Items
stArrayOfItem is ImportedWebserviceName.ArrayOfItem
arrArrayOfItem is array of ImportedWebserviceName.Item
stItem is ImportedWebserviceName.Item

stItem.WholesalerArtNr=stItemOrigem.WholesalerArtNr

...

Add(arrArrayOfItem,stItem)
stArrayOfItem.Item=arrArrayOfItem
stItems.Item=stArrayOfItem
stGetBackItems.items=stItems
END

RESULT stGetBackItems


Even though i could solve it, this is still a windev bug/error.
Mensaje modificado, 08,marzo 2018 - 16:40
Miembro registrado
16 mensajes
Publicado el 08,marzo 2018 - 16:41
stItemOrigin is ImportedWebserviceName.Item


was meant to be

stItemOrigem is ImportedWebserviceName.Item
Mensaje modificado, 08,marzo 2018 - 16:42