我试图将文件从iPhone上传到服务器.我试图避免使用任何不是由apple制作的库,而且我可以告诉它看起来我需要在构建我的请求时达到相当低的水平.有人能告诉我multipart/form-data请求中的"边界"是什么以及如何正确使用它?
任何人都可以帮助我使用mvc http post将参数传递给worldpay网站,下面是我在google上找到的示例,示例正在查看,但我想通过http [post]动作控制器传递参数:
<form method="post" action="https://secure.wp3.rbsworldpay.com/wcc/purchase" id="frmWorldPay">
<input type="hidden" name="instId" value="1" />
<input type="hidden" name="cartId" value="<%: Model.CardID %>" />
<input type="hidden" name="currency" value="GBP" />
<input type="hidden" name="amount" value="<%= Model.Cost%> " />
<input type="hidden" name="desc" value="<%: ViewBag.Name %> track day" />
<input type="hidden" name="email" value="<%: Model.aspnet_Users.aspnet_Membership.Email %>" />
<input type="hidden" name="name" value="<%: Model.FullName %>" />
<input type="hidden" name="address" value="<%: Model.Address %>" />
<input type="hidden" name="testMode" value="100" />
Run Code Online (Sandbox Code Playgroud) 我有一个要求,我必须根据输入参数使用c#(大小可以在10mb到400mb之间)下载一个zip文件.例如,下载userId = 10和year = 2012
的报告.Web 服务器接受这两个参数并返回一个zip文件.如何使用WebClient类实现此目的?
谢谢
我无法通过Android应用向服务器发送帖子请求.我找到了一些关于如何发送POST的例子,但我的代码有一些错误,这里是代码:
public class MainActivity extends Activity
{
private WebView wv; //Internet
private EditText email1; //Edit's
private EditText email2; //Edit's
private Button btn_get_access; //Get Access
private String post_url = "http://rasnacis.lv/vova.php";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wv = (WebView) findViewById(R.id.webView1);
email1 = (EditText) findViewById(R.id.txt_email_1);
email2 = (EditText) findViewById(R.id.txt_email_2);
btn_get_access = (Button) findViewById(R.id.btn_get_access);
WebSettings webSettings = wv.getSettings();
webSettings.setSaveFormData(true);
//BUTTON
OnClickListener ocl_btn_get_access = new OnClickListener()
{
public void onClick(View v)
{
String givenEmail1 = email1.getEditableText().toString();
String givenEmail2 = email2.getEditableText().toString(); …Run Code Online (Sandbox Code Playgroud) 这个"问题"要求澄清答案: 如何使用LWP发出JSON POST请求?
我没有评论答案的声誉,并认为将我的问题作为答案发布是不合适的.
具体来说,我试图发布JSON数据(就像其他问题提问者一样)而不是键值对.
为什么这样做:
my $lwp = LWP::UserAgent->new;
my $req = HTTP::Request->new( 'POST', $uri );
$req->header( 'Content-Type' => 'application/json' );
$req->content( $json );
my $response = $lwp->request( $req );
Run Code Online (Sandbox Code Playgroud)
但这不是:
my $req= POST( $uri, $json); ### this works for key/value pairs
$req->header( 'Content-Type' => 'application/json' );
my $response = $lwp->request( $req);
Run Code Online (Sandbox Code Playgroud)
......这也不是:
my $response = $lwp->request(POST $uri, ['Content-Type' => 'application/json'], $json);
Run Code Online (Sandbox Code Playgroud)
我已经阅读了HTTP :: Request :: Common和LWP :: Useragent的手册,我想我只是看错了.
同样,第一个例子运作良好,但我真的想更好地理解这一点.
谢谢.
我有以下Spring Integration配置.我在这里做的是dequeuing来自主题的消息,并在转换后将其发送到某个HTTP位置.
JMS Connection Factory 配置如下:
<bean id="inboundCF"
class="org.springframework.jms.connection.CachingConnectionFactory">
<constructor-arg index="0">
<jee:jndi-lookup jndi-name="java:comp/resource/ABC_AQ/XATopicConnectionFactories/XATCF" />
</constructor-arg>
<property name="sessionCacheSize" value="3" />
</bean>
<bean id="txInboundCF"
class="org.springframework.jms.connection.TransactionAwareConnectionFactoryProxy">
<property name="targetConnectionFactory" ref="inboundCF" />
<property name="synchedLocalTransactionAllowed" value="true" />
</bean>
Run Code Online (Sandbox Code Playgroud)
并Message Listener Container配置如下:
<bean id="jmsInboundContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer"
destroy-method="destroy">
<property name="connectionFactory" ref="txInboundCF" />
<property name="destination" ref="inboundDestination" />
<property name="pubSubDomain" value="true" />
<property name="sessionTransacted" value="true" />
<property name="errorHandler" ref="errorHandlerService" />
<property name="subscriptionDurable" value="true" />
<property name="durableSubscriptionName" value="mySub" />
<property name="cacheLevel" value="3" />
</bean>
<int-jms:message-driven-channel-adapter channel="jmsInChannel" …Run Code Online (Sandbox Code Playgroud) 我正在尝试Java Play,我遇到了直接的障碍.情况非常简单,设置简单.
我有一个名为的模型类Person非常简单,看起来像这样;
package models.models;
import play.db.ebean.Model;
import javax.persistence.Entity;
import javax.persistence.Id;
/**
* Created by asheshambasta on 25/07/14.
*/
@Entity
public class Person extends Model {
@Id
public Integer id;
public String name;
}
Run Code Online (Sandbox Code Playgroud)
我的路线定义为;
POST /person controllers.Application.addPerson()
Run Code Online (Sandbox Code Playgroud)
接下来,我在addPerson里面有一个动作controllers.Application,就是这样
public static Result addPerson() {
Person person = form(Person.class).bindFromRequest().get();
person.save();
Logger.debug(person.toString());
Logger.debug(form().get("name"));
return redirect(controllers.routes.Application.index());
}
Run Code Online (Sandbox Code Playgroud)
index.scala.html看起来像:
@(message: String)
@main("Welcome to Play") {
<form action="@routes.Application.addPerson()" method="post">
<input type="text" name="name" />
<button>Add person</button>
</form>
}
Run Code Online (Sandbox Code Playgroud)
我还检查了我的浏览器调试工具,我看到name …
我正在开发基于WCF休息的服务.我在我的服务中编写了Get和Post方法,当我输入URL(JSON格式)时,Get方法能够工作(获取数据).
问题是,当我尝试对POST方法执行相同操作时,该URL正在导航到其他页面"找不到页面...".
我知道POST方法需要表单提交来处理请求.
出于这个原因,我尝试了chrome扩展(Simple Rest客户端,Advanced Rest客户端,Post man rest客户端)和Fiddler.
这里我发布我的服务方法 - Get方法(接口方法声明).
[OperationContract]
[WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "GetCategoryTypes/")]
List<CategoryType> GetCategoryTypes();
Run Code Online (Sandbox Code Playgroud)
这是我的POST方法
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "AddOrders/",
RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.WrappedRequest)]
int AddOrders(decimal amount, int tableID, DateTime orderDate, int isActive);
Run Code Online (Sandbox Code Playgroud)
这是我的服务的web.config文件.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ServiceBehaviour" allowCookies="true" messageEncoding="Mtom" />
</basicHttpBinding>
<webHttpBinding>
<binding name="ServiceBehaviour1" allowCookies="true"/>
</webHttpBinding> …Run Code Online (Sandbox Code Playgroud) 我对Android编程很新,最近获得了成功的HTTP Post请求,只是为了了解我的cookie没有存储在后续的Post/Get请求之间.我浏览了一下interweb,并找到了Android的Apache客户端和Java的HttpURLConnection的几个例子.我没有成功地将这两种方法应用到我当前的课程中,所以我想知道有经验的人是否可以查看我的代码并提供建议.
概括:
感谢任何帮助,谢谢.
webCreate.java
import android.util.Log;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.CookieHandler;
import java.net.CookieManager;
import java.net.HttpCookie;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class webCreate {
private final String USER_AGENT = "Mozilla/5.0";
// HTTP GET request
public void sendGet(String url) throws Exception {
CookieManager cookieManager = new CookieManager();
CookieHandler.setDefault(cookieManager);
HttpCookie cookie = new HttpCookie("lang", "en");
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
// optional default is GET
con.setRequestMethod("GET");
//add request header …Run Code Online (Sandbox Code Playgroud) 是否可以将google maps api集成到html表单中,用户可以通过坐标的形式选择特定的针点位置并将其与表单一起提交?
我正在使用带有Razor视图的asp.net,但我怀疑无论如何都会影响这个问题的答案.
我查看了https://developers.google.com/maps/documentation/javascript/tutorial,似乎无法使用maps api作为表单输入.除非我是盲目的.