我创建了一个C#ASP.NET网页(前端)来收集用户的信息,我想知道如何将信息发送到java Web服务来处理来自网页的信息?< / p>
答案 0 :(得分:0)
您的Java Web服务应该使用SOAP / REST / Plain HTTP等协议进行讨论,并且需要在提交表单时从ASP.NET页面中适当地构造请求,并将请求发送到Java Web服务。
答案 1 :(得分:0)
启用WEBSERVICE [System.Web.Script.Services.ScriptService] 您可以使用JAVASCRIPT从WEBSERVICE访问数据
答案 2 :(得分:0)
这篇文章How to invoke Java web service in ASP.net using C#会给你一些指导。基本上,您需要:
Bikash Shaw的上述教程旨在使用名为JSimpCalcWebService
的Java Web服务开发简单的数学函数,如加法,减法等:
package calc.ws;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import calc.util.NumberFormater;
/**
* @author Bikash Shaw
*/
@WebService()
public class JSimpCalcWebService {
/**
* Web service operation
*/
@WebMethod(operationName = "addition")
public String addition(@WebParam(name = "parameter1")
double parameter1, @WebParam(name = "parameter2")
double parameter2) {
//TODO write your implementation code here:
return NumberFormater.format((parameter1 + parameter2),0,6);
}
}
用于调用Web服务的示例C#代码:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using JSimpCalcWebServiceService;
public partial class _Default : System.Web.UI.Page
{
JSimpCalcWebServiceService.JSimpCalcWebServiceService proxy;
protected void Page_Load(object sender, EventArgs e)
{
proxy = new JSimpCalcWebServiceService.JSimpCalcWebServiceService();
}
protected void btnAddition_Click(object sender, EventArgs e)
{
try
{
lblResultAddition.Text = "Result: " + proxy.addition(double.Parse(txtbtnAdditionParameter1.Text),
double.Parse(txtbtnAdditionParameter2.Text));
}
catch (FormatException)
{
lblResultAddition.Text = "Result: Invalide Input";
}
UpdatePanelAddition.Update();
}
// Add more methods here...
}