none
Post in JQuery XML using WCF RRS feed

  • Question

  • I tried testing my WCF with the Visual Studio tool called WCF Test Client. It works perfectly returning an XML structure. When I try doing the same process within Chrome console writing JQuery statement. So I was expecting to get a result saying "Data Insert Success". So Im going to let you see what Ive done so far.

    WCF Test Client:

    -IP:PORT/WebService.svc

    -Request

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Header>
        <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IWebService/ValidarDatosClientes</Action>
      </s:Header>
      <s:Body>
        <ValidarDatosClientes xmlns="http://tempuri.org/">
          <campaña>test</campaña>
          <nombre1>alejandro</nombre1>
          <nombre2>paul</nombre2>
          <apellido1>fernandez</apellido1>
          <apellido2>cortez</apellido2>
          <documento>5478562457</documento>
          <email>johnpaul@mail.com</email>
          <genero>masculino</genero>
          <telefonoFijo>2548654</telefonoFijo>
          <telefonoCelular>0985452158</telefonoCelular>
          <fechaNacimiento>1989/10/07</fechaNacimiento>
        </ValidarDatosClientes>
      </s:Body>
    </s:Envelope>

    -Response:

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Header />
      <s:Body>
        <ValidarDatosClientesResponse xmlns="http://tempuri.org/">
          <ValidarDatosClientesResult>1.0-&gt;Información ingresada exitosamente.</ValidarDatosClientesResult>
        </ValidarDatosClientesResponse>
      </s:Body>
    </s:Envelope>

    The method for this web service is ValidarDatosClientes(). So this perfectly works.

    What I want is to have a similar response within the Chrome console using JQuery.

    Ive been getting errors like 400/ 400 Bad Request or even "Undefined"

    jQuery.ajax({
        url: "http://IP(Hidden for security):PORT",
        data: "<campaña>test</campaña>"
          "<nombre1>alejandro</nombre1>"
          "<nombre2>paul</nombre2>"
          "<apellido1>fernandez</apellido1>"
          "<apellido2>cortez</apellido2>"
          "<documento>5478562457</documento>"
          "<email>johnpaul@mail.com</email>"
          "<genero>masculino</genero>"
          "<telefonoFijo>2548654</telefonoFijo>"
          "<telefonoCelular>0985452158</telefonoCelular>"
          "<fechaNacimiento>1989-1220*07</fechaNacimiento>",
        type: 'POST',
        contentType: "text/xml",
        dataType: "text",
        success : parse,
        error : function (xhr, ajaxOptions, thrownError){  
            console.log(xhr.status);          
            console.log(thrownError);
        } 
    }); 

    Im using the console on the same domain. Thank you very much in advance.

    Friday, June 15, 2018 4:40 PM

All replies

  • Hi gangrelg,

    I suggest you try to set "processData: false," in ajax like below:

    $.ajax({
        url: webServiceURL, 
        type: "POST",
        dataType: "xml", 
        data: soapMessage, 
        processData: false,
        contentType: "text/xml; charset=\"utf-8\"",
        success: OnSuccess, 
        error: OnError
    });

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, June 18, 2018 5:40 AM