Je rencontre des problèmes avec l'un des services de nettoyage que j'utilise. J'utilise soap4r
pour consommer le service de savon. Mais d'une manière ou d'une autre, ils attendent autre chose que ce que j'envoie. Voici ce que j'envoie: Problème lors de l'utilisation de soap4r, impossible d'ajouter un espace de nom, style d'encodage à l'enveloppe de savon
<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<authenticate env:mustUnderstand="0">
<username>USERNAME</username>
<apiKey>API_KEY</apiKey>
</authenticate>
<SoftLayer_Network_Media_Transcode_AccountInitParameters env:mustUnderstand="0">
<id>ID</id>
</SoftLayer_Network_Media_Transcode_AccountInitParameters>
<SoftLayer_Network_Media_Transcode_AccountObjectFilter env:mustUnderstand="0">
<transcodeJobs>
<transcodeStatus>
<name>
<operation>Complete</operation>
</name>
</transcodeStatus>
</transcodeJobs>
</SoftLayer_Network_Media_Transcode_AccountObjectFilter>
</env:Header>
<env:Body>
<n1:getTranscodeJobs xmlns:n1="http://api.service.softlayer.com/soap/v3/"
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
</n1:getTranscodeJobs>
</env:Body>
</env:Envelope>
Ce qui ne renvoie pas la sortie désirée. Ce qu'ils attendent est:
<?xml version="1.0" encoding="utf-8" ?> <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n1="http://api.service.softlayer.com/soap/v3/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <env:Header> <authenticate env:mustUnderstand="0"> <username>USER_NAME</username> <apiKey>API_KEY</apiKey> </authenticate> <SoftLayer_Network_Media_Transcode_AccountInitParameters env:mustUnderstand="0"> <id>id</id> </SoftLayer_Network_Media_Transcode_AccountInitParameters> <n1:SoftLayer_Network_Media_Transcode_AccountObjectFilter env:mustUnderstand="0"> <transcodeJobs> <transcodeStatus> <name> <operation>Complete</operation> </name> </transcodeStatus> </transcodeJobs> </n1:SoftLayer_Network_Media_Transcode_AccountObjectFilter> </env:Header> <env:Body> <n1:getTranscodeJobs > </n1:getTranscodeJobs> </env:Body> </env:Envelope>namespace et style de codage dans la racine (comme ils l'utilisent dans l'en-tête ObjectFilter). soap4r génère la requête précédente, et je ne suis pas en mesure de la changer pour la dernière qui fonctionne réellement.
Voici comment j'utilise soap4r:
class SLHeader < SOAP::Header::SimpleHandler
def initialize(tag, out)
@out = out
super(XSD::QName.new(nil, tag))
end
def on_simple_outbound
@out
end
end
SOAP_WSDL_ENDPOINT = "endpoint"
service = "service name"
initParams = {'id' => ID}
objectFilter = {'transcodeJobs' => {'transcodeStatus' => {'name' => {'operation' => STATUS}}}}
driver = SOAP::WSDLDriverFactory.new(SOAP_WSDL_ENDPOINT + service + "?wsdl").create_rpc_driver
driver.headerhandler << SLHeader.new('authenticate', {'username' => @auth_user, 'apiKey' => @auth_key})
driver.headerhandler << SLHeader.new(service + 'InitParameters', initParam)
driver.headerhandler << SLHeader.new(service + 'ObjectFilter', objectFilter)
pouvez-vous me signaler quelques tutoriels élaboratifs, comme je suis nouveau à savon ainsi que handsoap. – bhups
@bhups, le wiki est un bon début, voir: http://wiki.github.com/unwire/handsoap/recommendations – molf