Skip to main content
Fabiano Magno Pechibella
Inspiring
November 14, 2014
Answered

Send information to a WS

  • November 14, 2014
  • 1 reply
  • 1151 views

Hi CFers,

I have this form, and I have which send information to a web service:

How I can?

FORM

<input type="text" name="name">

<input type="text" name="cpf">

<input type="text" name="inscricaoEstadual">

<input type="text" name="email">

WS

<xs:complexType name="cliente">

        <xs:sequence>          

            <xs:element minOccurs="0" name="name" type="tns:clienteContato"/>

            <xs:element minOccurs="0" name="cpf" type="xs:long"/>

            <xs:element minOccurs="0" name="inscricaoEstadual" type="xs:string"/>

            <xs:element minOccurs="0" name="email" type="xs:long"/>

        </xs:sequence>

Tks

This topic has been closed for replies.
Correct answer BKBK

Hi BKBK,

Follows the code in the page WS.CFM

<cfif isDefined("form.email")>

    <cfset cliente = structNew()>

    <cfset cliente.NomeFantasia = form.NomeFantasia>

    <cfset cliente.documento = form.documento>

    <cfset cliente.inscricaoEstadual = form.inscricaoEstadual>

    <cfset cliente.email = form.email>

    <cfset cliente.endereco1 = form.endereco1>

    <cfset cliente.endereco2 = form.endereco2>

    <cfset cliente.cidade = form.cidade>

    <cfset cliente.estado = form.estado>

    <cfset cliente.cep = form.cep> 

</cfif>

<form action="http://0.0.0.0:8080/0WS/services/ClienteWSService?wsdl" method="post" name="ContactForm" id="contactForm">

    <input type="text" class="input-box" name="nome" placeholder="Digite a Razão Social." id="nome">

    <input type="text" class="input-box" name="nomeFantasia" placeholder="Digite o Nome de Fantasia." id="nomeFantasia">

    <input type="text" class="input-box" name="documento" placeholder="Digite o CNPJ." id="documento">

    <input type="text" class="input-box" name="inscricaoEstadual" placeholder="Digite Inscrição Estadual." id="inscricaoEstadual">

    <input type="text" class="input-box" name="endereco1" placeholder="Digite o Endereço." id="endereco1">

    <input type="text" class="input-box" name="endereco2" placeholder="Digite o Endereço." id="endereco2">

    <input type="text" class="input-box" name="cidade" placeholder="Digite a Cidade." id="cidade">

    <input type="text" class="input-box" name="estado" placeholder="Assunto." id="estado">

    <input type="text" class="input-box" name="cep" placeholder="Assunto." id="cep">

    <input type="submit" name="submitf" id="submitf" value="Send to Webservice">

</form>

In the same form, I have more information, like Representante Legal for the Representate Legal I create other struct or inside this same CFIF I can put the information like <cfset cliente.NomeFantasia = form.NomeFantasia> and <cfset cliente.Nome= form.Nome>?

It's correct?

Best Regards and Tks for your help!!!

Fabiano


You have now made it more complicated. To return to your original question,

I have this form, and I have which send information to a web service:

How I can?

FORM

<input type="text" name="name">

<input type="text" name="cpf">

<input type="text" name="inscricaoEstadual">

<input type="text" name="email">

WS

<xs:complexType name="cliente">

        <xs:sequence>          

            <xs:element minOccurs="0" name="name" type="tns:clienteContato"/>

            <xs:element minOccurs="0" name="cpf" type="xs:long"/>

            <xs:element minOccurs="0" name="inscricaoEstadual" type="xs:string"/>

            <xs:element minOccurs="0" name="email" type="xs:long"/>

        </xs:sequence>


form.cfm


<form action="../ws/ws.cfm" method="post" name="ContactForm" id="contactForm">

    <input type="text" name="name">

     <input type="text" name="cpf">

     <input type="text" name="inscricaoEstadual">

    <input type="text" name="email">

    <input type="submit" name="submitf" id="submitf" value="Send to Webservice">

</form>



ws.cfm


<cfif isDefined("form.email")>

<cfset cliente. = structNew()>

<cfset cliente.name = form.name>

<cfset cliente.cpf = form.cpf>

<cfset cliente.inscricaoEstadual = form.inscricaoEstadual>

<cfset cliente.email = form.email>

<cfset ws = createObject("webservice", "http://0.0.0.0:8080/0WS/services/ClienteWSService?wsdl">

<cfset result = ws.wsOperation(cliente)>

</cfif>

1 reply

BKBK
Community Expert
Community Expert
November 16, 2014

For example, on the action page of the form, do something like

<cfif isDefined("form.email")>

<cfset cliente. = structNew()>

<cfset cliente.name = form.name>

<cfset cliente.cpf = form.cpf>

<cfset cliente.inscricaoEstadual = form.inscricaoEstadual>

<cfset cliente.email = form.email>

</cfif>

Then call the web service, passing the parameter cliente.

Fabiano Magno Pechibella
Inspiring
November 16, 2014

BKBK,

Today, my code is:

--- PAGE FORM.CFM ---

<form action="../ws/ws.cfm" method="post" name="ContactForm" id="contactForm">

    <input type="text" name="name">

    <input type="text" name="cpf">

    <input type="text" name="inscricaoEstadual">

    <input type="text" name="email">

</form>

--- PAGE WS.CFM ---

<cfhttp url="http://0.0.0.0:8080/services/ClienteWSService?wsdl" method="Post" result="teste" resolveurl="false" charset="utf-8">

    <cfhttpparam name="name" value="#form.nome#" type="formfield" >

     <cfhttpparam name="cpf" value="#form.cpf#" type="formfield">

    <cfhttpparam name="inscricaoEstadual" value="#form.inscricaoEstadual#" type="formfield">

    <cfhttpparam name="email" value="#form.email#" type="formfield">  

</cfhttp>

That is correct?

If not,

Can you put some example to how I can call the web service, to passing the cliente information?

Tks,

Fabiano

BKBK
Community Expert
Community Expert
November 17, 2014

You miss the form's submit button: <input type="submit" name="sbmt" value="Send to Webservice">

Also, you ignored the suggestion I gave you. In any case, I will repeat it.

In the page ws.cfm, create the cliente structure, as I suggested, and pass it to the service.