Jump to content

Recommended Posts

Posted

Boas,

A minha duvida é a seguinte:

  • Existe um site que processa e manda uma mensagem em xml para a minha pagina asp, agora como é que eu vou ler essa mensagem xml para depois puder trata-la?

Penso que devo ter que ler a mensagem no load da minha página, mas falta-me o como vou ler.

Obrigado pelas dicas

  • 4 weeks later...
Posted

Boas,

e como é que o site está a mandar a mensagem em xml? POST?

Se tiveres controlo sobre os 2 sites, o que normalmente faço é criar uma página com webservices (.asmx) e crio uma função que permite receber conteúdo.

No site de origem, chama a função do webservice no site destino, enviando o conteúdo que precisa.

Posted

Cá vai um pequeno exemplo de um livro como usar jquery com asmx webservices ("ASP.NET jQuery Cookbook ISBN 978-1-849690-46-1") :

In addition to page methods, jQuery also enables the making of AJAX calls to web services. In

this recipe, we will validate the username keyed in by the end user by making a call to a web

service instead.

1. Add a web service UserNameWS.asmx to the current project.

2. Add the following namespace to the code-behind:

using System.Web.Services;

3. To enable the web service to be called using AJAX, add the following:

[system.Web.Script.Services.ScriptService]

4. Add a web method to validate the username as follows:

[WebMethod]
public bool CheckUserName(string sUserName)
{
 string[] UserNameArray;
 UserNameArray = new string[7] { "testid01", "testid02",
 "testid03", "testid04", "testid05", "testid06", "testid07" };
 foreach (string strUsername in UserNameArray)
 {
 if (sUserName == strUsername)
   return true;
 }
 return false;
}

5. Add a new web form Recipe4.aspx to the current project.

6. Add a TextBox and a Button control to the form as follows:

<form id="form1" runat="server">
 <div>
   <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
   <asp:Button ID="btnSubmit" runat="server" Text="Check User Name" />
 </div>
</form>

the complete jQuery solution is as follows:

<script language="javascript" type="text/javascript">
$(document).ready(function() {
 $("#btnSubmit").click(function(e) {
   e.preventDefault();
   if ($("#txtUserName").val() == '')
     alert("Please enter the UserName");
   else
     sendData($("#txtUserName").val());
 });
 function sendData(sUserName) {
   $.ajax({
     type: "POST",
     url: "UserNameWS.asmx/CheckUserName",
     data: '{"sUserName":"' + sUserName + '"}',
     contentType: "application/json; charset=utf-8",
     dataType: "json",
     success: function(msg) {
       if (msg.d)
         alert("The User Name is valid");
       else
         alert("The User Name is invalid")
     },
     error: function() {
       alert("An unexpected error has occurred during processing.");
     }
   });
 }
});
</script>

Espero que seja util.

.NET/T-SQL, JAVA, PHP, Javascript Developer | Business Intelligence | Gestão de Sistemas de Informação Empresariais

Posted

Obrigado pelas resposta.

Eu resolvi da seguinte maneira, recebi a mensagem encriptada no asp e enviei para uma servlet, e ai no java é que fiz o

tratamento dos dados e verificações necessárias.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.