입력란의 값을 내 webservice에 게시해야합니다. 인터넷에서 검색하면 운이 전혀 없습니다. AJAX/JSon을 사용하여 WCF를 통해서만 데이터를 랩핑하고 게시 할 수 없습니다. 그리고 나는 그것에 매달렸다. 누군가가 도울 수 있기를 바랍니다.양식 작업을 통해 데이터를 전달하는 방법 - WebService (WCF)의 "POST"?
HTML 파일 :
공간 소비를 최소화하기 위해 일부 필드를 제거합니다.
<%@ Page Language="C#" AutoEventWireup="ue" CodeBehind="WebForm1.aspx.cs" Inherits="BasePayment.Client.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//D HTML 4.01 ansitional//EN" "http://www.w3.org//html4/loose.d">
<html>
<body>
<form method="POST" name="frmPayment" action="">
Merchant ID
<input type="text" name="merchantId" value="1546" />
Payment Method
<input type="text" name="pMethod" value="VISA" />
Credit card expiry month - 2 digits.
<input type="text" name="epMonth" value="02" />
Credit card expiry year - 4 digits.
<input type="text" name="epYear" value="2012" />
Credit card number.
<input type="text" name="cardNo" value="4918914107195005" />
Credit Card Verification Code
<input type="text" name="securityCode" value="123" />
Credit card holder name
<input type="text" name="cardHolder" value="Juan Dela Cruz" />
Redirect to a URL upon failed ansaction:
<input type="text" name="failUrl" value="http://www.yahoo.com" />
Remark:
<input type="text" name="remark" value="Other Remarks" />
<input type="submit" value="Submit" id="btnSubmit"/>
</form>
</body>
</html>
WCF : WCF의
using System;
using System.Runtime.Serialization;
using System.ServiceModel;
using BasePayment.Entities;
using System.ServiceModel.Activation;
namespace BasePayment.WebService
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class PaymentComponent : IPaymentComponent
{
public void SendPayment(PaymentInformation payInfo)
{
PaymentInformation newPayInfo = new PaymentInformation();
/*Validation of input goes here ...
*
*
*
* */
// Then send data.
}
}
}
인터페이스 : 지불 정보를 원하시면
using System;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using BasePayment.Entities;
namespace BasePayment.WebService
{
[ServiceContract(Namespace="http://test.com/services/payment")]
public interface IPaymentComponent
{
[OperationContract]
[WebInvoke(UriTemplate="PaymentInfo", Method="POST")]
void SendPayment(PaymentInformation payInfo);
}
}
ENTITY :
내가 공간 소비를 최소화하기 위해 일부 속성을 제거합니다. ENTITY OF
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace BasePayment.Entities
{
public class PaymentInformation : IPaymentInformation
{
public PaymentInformation()
{
}
public int ExpiryMonth
{
get;
set;
}
public int ExpiryYear
{
get;
set;
}
public int CreditCardVerificationCode
{
get;
set;
}
public double Amount
{
get;
set;
}
public string Language
{
get;
set;
}
public string CardHolderName
{
get;
set;
}
public string Remark
{
get;
set;
}
}
}
INTERFACE : HERE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BasePayment.Entities
{
interface IPaymentInformation
{
long CreditCardNumber { get; set; }
long OrderReferenceID { get; set; }
int CurrencyCode { get; set; }
int MerchantID { get; set; }
int ExpiryMonth { get; set; }
int ExpiryYear { get; set; }
int CreditCardVerificationCode { get; set; }
double Amount { get; set; }
string Language { get; set; }
string CardHolderName { get; set; }
string URLUponFailed { get; set; }
string URLUponSuccess { get; set; }
string URLUponError { get; set; }
string Remark { get; set; }
PaymentMethod PaymentMethod { get; set; }
}
}
AND 내 프로젝트 PREVIEW이다 미리
감사 !!!
나는 묻지 않아도됩니다. 왜 WCF 서비스를 사용해야하나요? 왜 서버 측 코드에 다시 게시하고 유효성 검사/처리를 수행하지 않습니까? – Steve
'서버에 다시 게시'한다는 것은 무엇을 의미합니까? 내 주요 목표는 WCF Webservice를 사용하여 "FORM"에서 게시 된 데이터를 래핑하는 것입니다. 그것은 나에게 주어진 지시였다. 귀하의 회신에 감사드립니다. – fiberOptics