locked
How to send XML file to WSDL WebService RRS feed

  • Question

  • I created an XML file to be sent to a WSDL endpoint. How do I send the XML file to the Web knowing the username and password and to receive an answer?

    Is there a DLL or OCX?

    Thanks to all


    Danielito
    Sunday, September 26, 2010 10:14 AM

Answers

  • use winHttp:

    oWinHttp = Create('winhttp.winhttprequest.5.1')

    with oWinHttp

        .open('POST','www.yoursite.com', .f.)
        .setAutoLogonPolicy(1)
        .setCredentials("User Name", "Password",0)

        .setRequestHeader('content-type','text/xml')
        .send( cXmlString )

        messagebox('Status:'+trans(.status)+chr(13)+.responseText,0)

    endwith

    *

    Marco


    Marco Plaza

    Sunday, July 1, 2012 2:44 AM
  • WSDL = Web Service Description Language

    A WSDL file describes the endpoints of a web service, it's classes and methods.

    Depending on the type of webservice, you can eg use the MSSOAP.Soapclient as in

    SoapClient = createobject("MSSoap.SoapClient")
    SoapClient.mssoapinit("http://...service.wsdl")
    SoapClient.ConnectorProperty("AuthName") = "username"
    SoapClient.ConnectorProperty("AuthPassword") = "password"

    and then continue with calling the method. The service may also describe a certain login/authorisation method to use as the first step before calling anything else.

    It's all very proprietary, there is no general way to do it, as there is no general way to call a method of a class. Remember a webservice as SOAP Service is nothing else but a remotely instanciatec class with mehtods. The XML Soap messages are generated and sent by mssoap.soapclient.

    VFP has a wrapper around that in the Wsclient class of HOME()+"ffc\_webservices.vcx

    It all depends on the type of webservice. Having the WSDL location is not all you need to know, there are many types of webservices which offer different ways to authenticate and to communcate via several protocols. Even in reagard of soap there are several versions...

    In short: This can't be answered unless using the POST request methods already helped you. If you create Soap XML envelopes and messages on your own and parse the results, you're missing the comfort of the mssoap.soapclient class to do that for you.

    Bye, Olaf.




    Sunday, July 1, 2012 5:58 PM
  • Checkout the sample from the following link: 

    http://www.example-code.com/foxpro/soap_web_service.asp

    Good luck

    Victor

    Monday, July 2, 2012 7:41 PM

All replies

  •  

    Perhaps this will do it.

    oHTTP = create("microsoft.xmlHTTP")
    oHTTP.Open("POST", server_name, .f.)
    oHTTP.setRequestHeader("content-type","text/xml")
    oHTTP.send( filetostr( my_xml_file ) )
    ? xmlhttp.responseText

    Sunday, September 26, 2010 10:50 AM
  • WSDL isn't a web service type. Do you mean SOAP?
    Craig Berntson
    MCSD, Visual FoxPro MVP
    INETA Regional Speaker
    www.craigberntson.com
    Sunday, September 26, 2010 3:35 PM
  • Hi, Michel

    Sorry for the late reply.

    Your example seems to work well. In the sense that I get a response.
    But when I send the statement "oHTTP.send( filetostr( my_xml_file ) )"
    a basic authentication i required.
    I have got Username and password effectively.
    What should I add?
    I had to replace the statement "? xmlhttp.responseText" with "? oHTTP.responseText" to receive an answer. Is it right ?
    Thank you very much for the help because for me it is very important
    Regards
     Daniele

    Danielito
    Wednesday, September 29, 2010 7:15 AM
  • oHTTP = create("microsoft.xmlHTTP")
    sURL = "http://mysite/mypath/validateuser.asp?username + userid"
    oHTTP.Open("POST", sUrl, .f.)
    oHTTP.setRequestHeader("content-type","text/xml")
    oHTTP.send( filetostr( my_xml_file ) )
    ? oHTTP.responseText
    
    
    Wednesday, September 29, 2010 9:54 AM
  • Hi Michel,

    I did as you told me but it doesn't work.

    I write:

    oHTTP.Open("POST","https://mysite/mypath/sendrequest?username=myuser&password=mypassword" , .f.)

    and here OK, than

    oHTTP.setRequestHeader("content-type","text/xml")

    and here OK, than

    oHTTP.send( filetostr("myfile.xml"))
    at this point i show me  the classic form to request Username and Password.

    The web page sendrequest is not .asp or .html but it's an endpoint address

    Please help me.

    regards

     

     


    Danielito
    Wednesday, September 29, 2010 1:24 PM
  • Still an issue?

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Experience Program Manager (Blog, Twitter, Wiki)

    Friday, June 29, 2012 11:29 PM
  • use winHttp:

    oWinHttp = Create('winhttp.winhttprequest.5.1')

    with oWinHttp

        .open('POST','www.yoursite.com', .f.)
        .setAutoLogonPolicy(1)
        .setCredentials("User Name", "Password",0)

        .setRequestHeader('content-type','text/xml')
        .send( cXmlString )

        messagebox('Status:'+trans(.status)+chr(13)+.responseText,0)

    endwith

    *

    Marco


    Marco Plaza

    Sunday, July 1, 2012 2:44 AM
  • WSDL = Web Service Description Language

    A WSDL file describes the endpoints of a web service, it's classes and methods.

    Depending on the type of webservice, you can eg use the MSSOAP.Soapclient as in

    SoapClient = createobject("MSSoap.SoapClient")
    SoapClient.mssoapinit("http://...service.wsdl")
    SoapClient.ConnectorProperty("AuthName") = "username"
    SoapClient.ConnectorProperty("AuthPassword") = "password"

    and then continue with calling the method. The service may also describe a certain login/authorisation method to use as the first step before calling anything else.

    It's all very proprietary, there is no general way to do it, as there is no general way to call a method of a class. Remember a webservice as SOAP Service is nothing else but a remotely instanciatec class with mehtods. The XML Soap messages are generated and sent by mssoap.soapclient.

    VFP has a wrapper around that in the Wsclient class of HOME()+"ffc\_webservices.vcx

    It all depends on the type of webservice. Having the WSDL location is not all you need to know, there are many types of webservices which offer different ways to authenticate and to communcate via several protocols. Even in reagard of soap there are several versions...

    In short: This can't be answered unless using the POST request methods already helped you. If you create Soap XML envelopes and messages on your own and parse the results, you're missing the comfort of the mssoap.soapclient class to do that for you.

    Bye, Olaf.




    Sunday, July 1, 2012 5:58 PM
  • Checkout the sample from the following link: 

    http://www.example-code.com/foxpro/soap_web_service.asp

    Good luck

    Victor

    Monday, July 2, 2012 7:41 PM