Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
To develop interface from VFP to WS but not know how
Message
De
09/10/2020 16:24:33
 
 
À
09/10/2020 13:54:45
Information générale
Forum:
Visual FoxPro
Catégorie:
Web Services
Divers
Thread ID:
01676523
Message ID:
01676575
Vues:
26
>>>>I guess I have advanced a little with this:
>>>>
>>>>
>>>>loHTTP= CREATEOBJECT("MSXML2.ServerXMLHTTP.6.0")
>>>>loHTTP.Open("POST", "https://api-test.mypartner.com/", .F.)
>>>>loHTTP.Setrequestheader("Content-type", "application/x-www-form-urlencoded")
>>>>loHTTP.Send("json=" + m.lcJsonString)
>>>>
>>>>
>>>>It returns me an html string which says:
>>>>
>>>>Server error
>>>>405 - HTTP verb used to access this page is not allowed.
>>>
>>>Try with get instead of post. Also, try to add the "json=..." part to the url, as a parameter, urlencoded - as you announced when you asked for the header.

>>
>>The code that I showed. Was almost a copy/paste (except for the urls and data) code that I used in another interface I developed some months ago and is still working flawlessly, thanks to Antonio Lopes.
>>
>>I'll tried your suggestion. But yet I can't send the json. I used POST because in the documentation (which I showed in my first post) at the "Endpoint" description, it says:
>>
>>POST /wcf-services/service-customs.svc/customs/insert_customs_data
>>
>>Altought is not referring to the main URL but a path. I tried to POST to /wcf-services/service-customs.svc/customs/insert_customs_data but VFP gave me an error.
>>
>>It looks like it's something simple but I can't imagine it.
>>
>>Thanks anyway.
>>
>
>Luis, you're posting to the wrong address. I would imagine it would be something like
>
>loHTTP.Open("POST","https://api-test.mypartner.com/wcf-services/service-customs.svc/customs/insert_customs_data",.f.)
>
Thanks Antonio, I tried and it doesn't give any error then I call:
loHTTP.Setrequestheader("Content-type", "application/x-www-form-urlencoded")
loHTTP.Send("json=" + m.lcJsonString)
lcRespJSON= ''+ This.oHTTP.Responsebody
Last VFP command returns the following into "lcRespJSON" varfiable:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Request Error</title>
    <style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>
  </head>
  <body>
    <div id="content">
      <p class="heading1">Request Error</p>
      <p>The server encountered an error processing the request. The exception message is 'The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'. This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details.'. See server logs for more details. The exception stack trace is: </p>
      <p>   at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</p>
    </div>
  </body>
</html>
Any ideas/suggestions?

TIA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform