2017-07-25 1 views
0

J'essaie d'utiliser un service web en utilisant le paquet RCurl.Accéder à des services web en utilisant RCurl CurlPerform: Obtenir l'erreur HTTP 500

Ce webservice « https://ngcsi.contigohosting.com/Entrader_Dev/wcfservices/TradingService.svc » a beaucoup de méthodes get qui peuvent être accédés par

authentification et donc je passe le nom d'utilisateur et mot de passe dans l'en-tête.

h=basicTextGatherer() 
headerFields = 
    c(c(Accept="text/xml", Accept="multipart/*", 
     'Content-Type' = "text/xml; charset=utf-8"), 
     SOAPAction = "https://ngcsi.contigohosting.com/Entrader_Dev/wcfservices/TradingService.svc?wsdl") 

body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 

xmlns:con="http://entrader.contigoenergy.com/Contigo.Entrader.Service">\ 
    <soapenv:Header>\ 
<wsse:Security soapenv:mustUnderstand="1"\ 
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">\ 
<wsse:UsernameToken wsu:Id="UsernameToken-37"\ 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">\ 
<wsse:Username>Username</wsse:Username>\ 
<wsse:Password 
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password>\ 
</wsse:UsernameToken>\ 
</wsse:Security>\ 
</soapenv:Header>\ 
<soapenv:Body>\ 
</soapenv:Body>\ 
</soapenv:Envelope>\n' 

curlPerform(url = "https://ngcsi.contigohosting.com/Entrader_Dev/wcfservices/TradingService.svc", 
      httpheader = headerFields, 
      postfields = body, 
      writefunction = h$update, 
      verbose=TRUE 
) 

body=h$value() 

Je reçois un HTTP/1.1 500 Internal Server Error lors de l'exécution ci-dessus et au-dessous est le contenu du corps

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2017-07-25T15:14:00.856Z</u:Created><u:Expires>2017-07-25T15:19:00.856Z</u:Expires></u:Timestamp></o:Security></s:Header><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode><faultstring xml:lang="en-GB">The message with Action 'https://ngcsi.contigohosting.com/Entrader_Dev/wcfservices/TradingService.svc?wsdl' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</faultstring></s:Fault></s:Body></s:Envelope> 

Toute aide est très appréciée. Je vous remercie.

Répondre

0

Le SOAPAction devrait avoir une méthode et dans ce cas pourrait être l'un des éléments suivants selon le wsdl utilisé ci-dessus.

http://entrader.contigoenergy.com/Contigo.Entrader.Service/TradingService/GetTrade 

http://entrader.contigoenergy.com/Contigo.Entrader.Service/TradingService/GetByFilterTrade

Ainsi, le nouveau code devrait ressembler à la

h=basicTextGatherer() 
headerFields = 
    c(c(Accept="text/xml", Accept="multipart/*", 
     'Content-Type' = "text/xml; charset=utf-8"), 
     SOAPAction = "http://entrader.contigoenergy.com/Contigo.Entrader.Service/TradingService/GetTrade") 

body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 

xmlns:con="http://entrader.contigoenergy.com/Contigo.Entrader.Service">\ 
    <soapenv:Header>\ 
<wsse:Security soapenv:mustUnderstand="1"\ 
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">\ 
<wsse:UsernameToken wsu:Id="UsernameToken-37"\ 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">\ 
<wsse:Username>Username</wsse:Username>\ 
<wsse:Password 
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password>\ 
</wsse:UsernameToken>\ 
</wsse:Security>\ 
</soapenv:Header>\ 
<soapenv:Body>\ 
</soapenv:Body>\ 
</soapenv:Envelope>\n' 

curlPerform(url = "https://ngcsi.contigohosting.com/Entrader_Dev/wcfservices/TradingService.svc", 
      httpheader = headerFields, 
      postfields = body, 
      writefunction = h$update, 
      verbose=TRUE 
) 

body=h$value() 

suivant le code ci-dessus fonctionne et je suis en mesure d'obtenir une réponse appropriée du webservice bien que je ne l'ai pas mentionné quoi que ce soit dans le corps dans l'exemple indiqué.