PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 22 → [WD22] Erro estruturas em resposta de WebService SOAP
[WD22] Erro estruturas em resposta de WebService SOAP
Débuté par José BRANDÃO, 12 fév. 2018 12:17 - 3 réponses
Membre enregistré
15 messages
Posté le 12 février 2018 - 12:17
Olá

Estou a desenvolver um webservice que será consumido por um website, no qual esse website me enviará pedidos de stocks de vários artigos.
Tenho um WSDL que tenho que respeitar (http://golfinhosoft.webdev-test.com/OMA_WEB/awws/OMA.awws…) e até ao momento é este todo o meu código:

As minhas estruturas ( o resultado seria o mesmo com classes ):
EErpAvailabilityStatus is Enumeration
unbekannt = "unbekannt"
verfuegbar = "verfuegbar"
nichtverfuegbar = "nichtverfuegbar"
teilvefuergbar = "teilvefuergbar"
alternativlagerverfuegbar = "alternativlagerverfuegbar"
nochnichtangefragt = "nochnichtangefragt"
END

QuantityExtended is structure
PackingUnit is string
MinQuantity is numeric
MaxQuantity is numeric
ExpectedDeliveryTime is string
// AvailState is EErpAvailabilityStatus
AvailState is string
END
Quantity is structure
Text is string
Value is numeric
QuantitieUnit is string
QuantityExtended is QuantityExtended
END
ArrayOfQuantity is structure
Quantity is array of Quantity
END
Location is structure
Id is string
Text is string
Quantity is ArrayOfQuantity
END
ArrayOfLocation is structure
Location is array of Location
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
ArrayOfPrice is structure
Price is array of Price
END
ArrayOfString is structure
'string' is array of string
END
Supplier is structure
Id is string
Text is string
END
ArrayOfSupplier is structure
Supplier is List of Supplier
END
Suppliers is structure
Supplier is ArrayOfSupplier
END
Customer is structure
Id is string
Text is string
END
ArrayOfCustomer is structure
Customer is List of Customer
END
Customers is structure
Customer is ArrayOfCustomer
END
ArrayOfItem is a structure
Item is array of Item
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
User is structure
CustomerId is string
PassWord is string
UserName is string
SID is string
END
GetArticleInformation is structure
User is User
Items is Items
END
GetBackItems is structure
Items is Items
ErrorCode is numeric
ErrorId is numeric
ErrorMessage is string
END
GetArticleInformationResponse is structure
GetArticleInformationResult is GetBackItems
END


Usando o SoapUI, o teste do webservice no website ou até mesmo o Windev, ao fazer o pedido com qualquer uma destas 3 opções, tudo funciona perfeitamente sem qualquer erro.
O problema aparece quando tento obter a resposta do webservice. Na estrutura resultado "GetBackItems" só recebo os campos "Error" mas não recebo a estrutura "Items".

Aqui está o meu código dentro do 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


Este é o meu pedido de teste do webservice em 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)


E é esta a resposta que recebo:




Aqui está o meu pedido em SoapUI (encurtado):
<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>


E é esta a resposta que recebo no 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>


Até agora encontrei um problema que pode ser o que está a causar o meu problema de não receber o campo Items:

Quando eu uso a função "Serialize" na variavel "stGetBackItems" dentro do webservice e gravo o texto de resultado num ficheiro para poder abrir, em vez de estar algo como <GetBackItems><Items><Item><Item><WholesalerArtNr>......, está como <GetBackItems><Items><Item><Item><Item><WholesalerArtNr>...., tem um <Item> a mais.

Isto não acontece só com o campo <Item> mas também com todos os outros que usam estruturas "ArrayOf....".
Os campos são: "<Location>", "<Quantity>", "<Price>", "<Supplier>" e "<Customer>".

Qualquer ajuda ou até uma pequena dica seria muito útil.

Obrigado
Membre enregistré
2 859 messages
Popularité : +89 (91 votes)
Posté le 12 février 2018 - 14:03
Bom dia

Veja esse vídeo, nos comentários tem o código fonte

Me adicione no Skype adrianoboller

https://m.youtube.com/watch…

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
15 messages
Posté le 08 mars 2018 - 16:32
Para alguém interessado no assunto ou que tenha um problema similar, a maneira como resolvi este problema foi:
Recebendo os 2 parametros com as estruturas que criei manualmente.
Construir e retornar as variaveis de estruturas usando as estruturas do webservice (importei o dito webservice fixo).

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

stGetBackItems is NomeWebserviceImportado.GetBackItems
stGetBackItems.ErrorCode = 0
stGetBackItems.ErrorId = 100
stGetBackItems.ErrorMessage = "SUCCESSO"

stItemOrigem is NomeWebserviceImportado.Item

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

stItem.WholesalerArtNr=stItemOrigem.WholesalerArtNr

...

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

RESULT stGetBackItems
Membre enregistré
15 messages
Posté le 08 mars 2018 - 16:43
De qualquer das maneiras, isto é um erro do windev que deveria ser resolvido.