【发布时间】:2011-03-22 11:08:54
【问题描述】:
我正在尝试向接受 XML 字符串的 .NET Web 服务发送 SOAP 请求。这是我存储在 char 数组中的示例 XML 字符串:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<BankDeposit xmlns="http://tempuri.org/">
<xmlParam>
<onlineTxn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.tempuri.org/">
<TXN>
<TxnID>17032011111230</TxnID>
<CCID>73467836483</CCID>
<ACNO>899000777</ACNO>
<TXAMT>52</TXAMT>
</TXN>
</onlineTxn>
</xmlParam>
</BankDeposit>
</soap12:Body>
</soap12:Envelope>
我用来提交到 .NET 网络服务的代码如下:
int PostRequest(void)
{
CURL *curl;
char buffer[2000]=//XML String to be sent.
int res = -1;
struct curl_httppost *post=NULL, *last=NULL;
struct curl_slist *headers = NULL;
unsigned int buffer_size = 2000;
fp = fopen("res.xml","w");
fpreq = fopen ("req.xml", "w");
curl=curl_easy_init();
if(curl)
{
headers = curl_slist_append(headers, "Content-type:application/soap+xml; charset=utf-8; action=\"http://tempuri.org/BankDeposit\"");
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_FILE, fp);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); //For writing the responses recieved
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, buffer_size);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buffer);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_func);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 60);
res = curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
printf("CURL Easy Perform Status Code: %d\n", res);
}
fclose(fp);
fclose(fpreq);
return res;
}
问题是:“内容没有发布到 Web 服务”。我已经调试了我的 .NET 服务,但它没有收到来自发件人的任何数据。
我的 Web 服务操作是:BankDeposit。
接受一个名为 ; 的参数类型的xml参数:字符串
请帮我解决这个问题。需要你的建议。
【问题讨论】: