Bonjour, je fais un projet en VB.NET, sous VS2010, framework 3, dans lequel je fais appel à un web service, je dois envoyer un fichier zip, je comprends que je dois faire une enveloppe SOAP, seulement voilà, je ne pige pas grand chose.
L'enveloppe SOAP à envoyer ressemble à cela:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/env
elope/"
xmlns:ser="http://service.sunat.gob.pe" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01
/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soapenv:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>20100066603MODDATOS</wsse:Username>
<wsse:Password>moddatos</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ser:sendBill>
<fileName>20100066603-01-F001-1.zip</fileName>
<contentFile>cid:20100066603-01-F001-1.zip</conten
tFile>
</ser:sendBill>
</soapenv:Body>
</soapenv:Envelope>
Je me suis basé sur cet exemple: http://www.example-code.com/vbdotnet/http_soap.asp
mais mon enveloppe est incorrecte, j'obtiens cela:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/env
elope/"
xmlns:ser="http://service.sunat.gob.pe" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01
/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soapenv:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>20100066603MODDATOS</wsse:Username>
<wsse:Password>moddatos</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
<fileName>20100066603-01-F001-1.zip</fileName>
<contentFile>cid:20100066603-01-F001-1.zip</conten
tFile>
</soapenv:Header>
<soapenv:Body/>
</soapenv:Envelope>
Voici mon code:
Dim soapReq As New Chilkat.Xml
soapReq.Encoding = "utf-8"
soapReq.Tag = "soapenv:Envelope"
soapReq.AddAttribute("xmlns:soapenv", "http://schemas.xmlsoap.org/soap/envelope/")
soapReq.AddAttribute("xmlns:ser", "http://service.sunat.gob.pe")
soapReq.AddAttribute("xmlns:wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-2004
01-wss-wssecurity-secext-1.0.xsd")
soapReq.NewChild2("soapenv:Header", "")
soapReq.NewChild2("soapenv:Body", "")
soapReq.FirstChild2()
soapReq.NewChild2("wsse:Security", "")
soapReq.FirstChild2()
soapReq.NewChild2("wsse:UsernameToken", "")
soapReq.FirstChild2()
soapReq.NewChild2("wsse:Username", "20100066603MODDATOS")
soapReq.NewChild2("wsse:Password", "moddatos")
soapReq.GetRoot2()
soapReq.GetParent2()
soapReq.NewChild2("ser:SendBill", "")
soapReq.FirstChild2()
soapReq.NewChild2("FileName", "20100066603-01-F001-1.zip")
soapReq.NewChild2("contentFile", "cid:20100066603-01-F001-1.zip")
soapReq.GetRoot2()
Des idées? Merci