Um Bom Dia a todos!
pois é estou a 3 dias tentando fazer um projeto no qual vou descrever para que todos q passarem aqui possam me ajudar!
Estou iniciando no flex mais ja senti facilidades em alguns processos!
Eu fiz um pequeno projeto em flex com um FORM e kero passar as ifnromações desse form para um servlet e essa servlet passar os parametros para um servidor que vai me receber com um arquivo .action (struts)!
Sò que já tentei e tentei, achei sobre CROSSDOMAIN… ja o criei do jeito que alguns tutoriasi pedem…
colokei ele no ROOT do TOM CAT,
na pasta RAIZ do meu projeto e NADA!
Então espero que alguém possa me ajudar por favor!!!
Vou colokar o erro e os código do flex do meu servlet e do meu crossdomain :
ERRO!!!
[RPC Fault faultString=“Erro de segurança ao acessar url” faultCode=“Channel.Security.Error” faultDetail=“Destino: DefaultHTTP”]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:345]
at mx.rpc::Responder/fault()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:68]
at mx.rpc::AsyncRequest/fault()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:113]
at DirectHTTPMessageResponder/securityErrorHandler()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:432]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/redirectEvent()
servlet.mxml
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%"
creationComplete="init()"
>
<fx:Script source="As/actions.as"/>
<fx:Declarations>
<s:HTTPService id="service"
url="http://localhost:8080/loja/serv"
method="POST"
resultFormat="text"
showBusyCursor="true"
useProxy="false"
>
<s:request >
<CodigoLoja>{CodigoLoja.text}</CodigoLoja>
<NumeroPedido>{NumeroPedido.text}</NumeroPedido>
<VencimentoBoleto>{VencimentoBoleto.text}</VencimentoBoleto>
<Valor>{Valor.text}</Valor>
<Parcela>{Parcela.text}</Parcela>
<FormaPagamento>{FormaPagamento.selectedItem.id}</FormaPagamento>
<nomeCliente>{nomeCliente.text}</nomeCliente>
<cpfCliente>{cpfCliente.text}</cpfCliente>
<emailCliente>{emailCliente.text}</emailCliente>
<voucherDesconto>{voucherDesconto.text}</voucherDesconto>
<urlRetorno>{urlRetorno.text}</urlRetorno>
</s:request>
</s:HTTPService>
<mx:StringValidator source="{nomeCliente}" property="text" minLength="4" maxLength="100"/>
<mx:EmailValidator source="{emailCliente}" property="text"/>
</fx:Declarations>
<mx:Panel horizontalAlign="center" paddingTop="20"
horizontalCenter="2" verticalCenter="18" width="585" height="468"
textAlign="center" fontSize="20" fontFamily="Verdana" fontWeight="bold"
fontStyle="normal" textDecoration="none" color="#0540FF" backgroundColor="#9BD0FC"
borderColor="#0F0E0E" chromeColor="#7EA7FC" borderAlpha="0.15" layout="absolute" contentBackgroundAlpha="0.27" title="LOJA TESTE | FLEX | VIA POST">
<mx:Form width="513" horizontalCenter="0" verticalCenter="0"
height="399" backgroundColor="#B6D7FD" borderVisible="false"
dropShadowVisible="true" cornerRadius="10" borderColor="#FFFFFF"
textAlign="left" borderAlpha="0.15">
<mx:HBox color="#000000" width="100%" height="38" borderStyle="outset" verticalAlign="middle">
<mx:FormItem label="Código da Loja :" fontSize="10" borderVisible="true" dropShadowVisible="true" width="50%" color="#090909" fontFamily="Georgia">
<s:TextInput id="CodigoLoja" width="100" fontSize="10" borderVisible="true" borderColor="#696969" text="Magento"/>
</mx:FormItem>
<mx:FormItem label="Número do Pedido :" fontSize="10" borderVisible="true" dropShadowVisible="true"
horizontalAlign="center" required="false" width="50%" color="#090909" fontFamily="Georgia">
<s:TextInput id="NumeroPedido" width="100" fontSize="10" borderVisible="true" borderColor="#696969" text="1"/>
</mx:FormItem>
</mx:HBox>
<mx:VBox color="#000000" width="481" height="95" borderStyle="outset" verticalAlign="middle" horizontalAlign="left">
<mx:FormItem label="Nome do Cliente :" labelWidth="120" fontSize="10" borderVisible="true" dropShadowVisible="true" color="#090909" fontFamily="Georgia">
<s:TextInput id="nomeCliente" width="330" text="Teste" fontSize="10" borderVisible="true" borderColor="#696969"/>
</mx:FormItem>
<mx:FormItem label="Email do Cliente :" labelWidth="120" fontSize="10" borderVisible="true" dropShadowVisible="true" color="#090909" fontFamily="Georgia">
<s:TextInput id="emailCliente" width="285" text="test@test.com" fontSize="10" borderVisible="true" borderColor="#696969"/>
</mx:FormItem>
<mx:FormItem label="CPF :" labelWidth="120" fontSize="10" borderVisible="true" dropShadowVisible="true" width="390" color="#090909" fontFamily="Georgia" x="44">
<s:TextInput id="cpfCliente" text="111.111.111-01" width="165" fontSize="10" borderVisible="true" borderColor="#696969"/>
</mx:FormItem>
</mx:VBox>
<mx:HBox borderStyle="solid" height="106" verticalAlign="middle" horizontalAlign="center" width="479">
<mx:VBox width="180" borderStyle="none" height="73" verticalAlign="middle" horizontalAlign="center">
<mx:FormItem label="Valor :" fontSize="10" borderVisible="true" dropShadowVisible="true" width="50%" color="#000000">
<s:TextInput id="Valor" width="110" fontSize="10" text="10000" borderVisible="true" borderColor="#696969"/>
</mx:FormItem>
<mx:FormItem label="Parcela :" fontSize="10" borderVisible="true" dropShadowVisible="true" width="50%" color="#090909" fontFamily="Georgia">
<s:TextInput id="Parcela" width="100" text="1" fontSize="10" borderVisible="true" borderColor="#696969"/>
</mx:FormItem>
</mx:VBox>
<mx:VBox borderStyle="none" horizontalAlign="left" height="95" verticalAlign="middle">
<mx:FormItem label="Forma Pagamento :" fontSize="10" borderVisible="true" dropShadowVisible="true" color="#090909" fontFamily="Georgia">
<s:ComboBox id="FormaPagamento" dataProvider="{frmPag}" width="131" color="0x000000" selectedIndex="0" fontSize="10"/>
</mx:FormItem>
<mx:FormItem label="Vencimento do Boleto :" fontSize="10" borderVisible="true" dropShadowVisible="true" width="50%" color="#090909" fontFamily="Georgia">
<s:TextInput id="VencimentoBoleto" text="10/10/2010" width="111" fontSize="10" borderVisible="true" borderColor="#696969"/>
</mx:FormItem>
<mx:FormItem label="Voucher de Desconto :" fontSize="10" borderVisible="true" dropShadowVisible="true" color="#090909" fontFamily="Georgia">
<s:TextInput id="voucherDesconto" text="0" width="122" fontSize="10" borderVisible="true" borderColor="#696969"/>
</mx:FormItem>
</mx:VBox>
</mx:HBox>
<mx:VBox borderStyle="outset" width="480" verticalAlign="middle" horizontalAlign="center" height="58">
<mx:FormItem label="URL de Retorno :" fontSize="10" borderVisible="true" dropShadowVisible="true" width="50%"
color="#090909" fontFamily="Georgia">
<s:TextInput id="urlRetorno" width="360"
text="http://www.superpay.com.br:8081/LojaTesteSuperPay/recebeParametros.jsp"
borderVisible="true" fontSize="7"
borderColor="#696969" enabled="false"/>
</mx:FormItem>
<mx:FormItem label="URL de Redirecionamento :" fontSize="10" borderVisible="true" dropShadowVisible="true"
color="#090909" fontFamily="Georgia">
<s:TextInput id="urlRedirecionamento"
text="http://www.superpay.com.br:8081/LojaTesteSuperPay/recebeParametros.jsp"
width="300" fontSize="7"
borderVisible="true"
borderColor="#696969" enabled="false"/>
</mx:FormItem>
</mx:VBox>
<mx:HBox borderStyle="outset" verticalAlign="middle" horizontalAlign="center" width="480" height="37">
<s:Button id="btnEnvia" label="ENVIAR" fontSize="12" color="#175988" focusColor="#FFFFFF" click="{service.send()}"/>
<s:Button id="btnLimpa" label="LIMPAR" fontSize="12" color="#175988" focusColor="#FFFFFF" click="{limpaTuDo()}" />
</mx:HBox>
</mx:Form>
</mx:Panel>
</s:Group>
servlet_main.java
package br.com.ernet.servlet;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class servlet_index extends HttpServlet {
private static final long serialVersionUID = 1L;
public servlet_index() {
super();
}
public String txt_saida;
public String getTXT() {
return txt_saida;
}
public void setTXT(String txt_saida) {
this.txt_saida = txt_saida;
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String CodigoLoja = request.getParameter("CodigoLoja");
int NumeroPedido = Integer.parseInt(request.getParameter("NumeroPedido"));
String Valor = request.getParameter("Valor");
int FormaPagamento = Integer.parseInt(request.getParameter("FormaPagamento"));
String VencimentoBoleto = request.getParameter("VencimentoBoleto");
String Parcela = request.getParameter("Parcela");
String nomeCliente = request.getParameter("nomeCliente");
String cpfCliente = request.getParameter("cpfCliente");
String emailCliente = request.getParameter("emailCliente");
String voucherDesconto = request.getParameter("voucherDesconto");
String urlRetorno = request.getParameter("urlRetorno");
/*
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println(
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n"+
"<html>\n " +
"<head>\n" +
"<title>LOJA TESTE ERNET ---RETORNO---</title>\n" +
"</head>\n" +
"<body>" +
"<center><H1>--- RESPOSTA DE DADOS VIA POST ---</H1>\n" +
"<br> CodigoLoja : "+ CodigoLoja+
"<br> NumeroPedido : "+NumeroPedido+
"<br> Valor : "+Valor+
"<br> NomeCliente :"+NomeCliente+
"<br> CpfCliente : "+CpfCliente+
"<br> EmailCliente :"+EmailCliente+
"<br> Parcela : "+Parcela+
"<br> VencimentoBoleto : "+VencimentoBoleto+
"<br> Desconto : "+voucherDesconto+
"<br> urlRetorno : "+urlRetorno+
"</center>"+
"</BODY>" +
"</HTML>");
setTXT("Dados do cliente " +"\r\n"+
"| Codigo da Loja : "+
CodigoLoja +
"\r\n"+"| Numero do Pedido :" +NumeroPedido+
"\r\n"+"| Valor :R$"+Valor+
"\r\n"+"| Forma de Pagamento :"+FormaPagamento+
"| "
);
Escreve();*/
response.sendRedirect(
"http://homologacao.superpay.com.br/superpayhomol/Pagamento.action?"
+"CodigoLoja="+CodigoLoja+
"NumeroPedido="+NumeroPedido+
"Valor="+Valor+
"FormaPagamento="+FormaPagamento+
"VencimentoBoleto="+VencimentoBoleto+
"Parcela="+Parcela+
"nomeCliente="+nomeCliente+
"cpfCliente="+cpfCliente+
"emailCliente="+emailCliente+
"voucherDesconto="+voucherDesconto+
"urlRetorno"+urlRetorno
);
}
public void Escreve(){
try{
// Cria arquivo!
//aqui voc� colocar o caminho que quiser! ex: C:etc.../nome_do_arquivo.txt
FileWriter fstream = new FileWriter("C:\\Users\\pc1\\workspace\\test_servlet\\src\\out.txt");
BufferedWriter out = new BufferedWriter(fstream);
out.write("LOJA TESTE ERNET");
out.newLine();
out.write(getTXT());
//Fecha a saida do arquivo!
out.close();
}catch (Exception e){
System.err.println("Erro: " + e.getMessage());
}
}
}
crossdoamin.xml
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" to-ports="*" />
<allow-http-request-headers-from domain="*" headers="SOAPAction"/>
</cross-domain-policy>
[b]DESDE Já AGRADEÇO a COOPERAÇÂO