【问题标题】:curl wsdl soap error - mismatched Actions between sender and receivercurl wsdl soap 错误 - 发送方和接收方之间的操作不匹配
【发布时间】:2014-02-23 23:21:29
【问题描述】:

我正在尝试使用 c API 将基于 curl 的肥皂请求发布到 url。我的 libcurl 版本是 curl 7.30.0 (i686-pc-linux-gnu) libcurl/7.30.0 OpenSSL/1.0.0 zlib/1.2.5。我收到以下错误。还有下面我用来发布请求的代码.我正在使用正确的肥皂动作以及“GetAuthToken”,为什么在发布请求时会发生此错误。提前致谢。

错误: 由于 EndpointDispatcher 的 ContractFilter 不匹配,接收方无法处理带有 Action '' 的消息。这可能是因为合约不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)

请求: 123456789

网址: http://x.xx.xx.xxx:20003/HIMS/SecurityService/?wsdl

示例代码:

int main() {

    CURL *curl;

    CURLcode res;

    struct curl_slist *headers = NULL;

    FILE *out_fd = (FILE *) 0;

    char errorbuf[300]="",filename[32]="Response.txt";

    char errmsg[256];

    int Timeout=120;

    int buffer_size = 0;

    char urlbuff[100]="";

    char buff[128] = "http://x.xx.xx.xxx:20003/HIMS/SecurityService/?wsdl";

    memset(urlbuff,0,sizeof(urlbuff));

    curl = curl_easy_init();

    buffer_size = strlen(buffer);
    if(curl)
    {

            out_fd = fopen (filename, "w");
            curl_easy_setopt(curl, CURLOPT_FILE, out_fd);
            headers = curl_slist_append(headers, "Content-type:text/xml;charset=utf-8; SOAPAction=GetAuthToken");
            sprintf(urlbuff,"%s",buff);

            curl_easy_setopt(curl, CURLOPT_URL, urlbuff);
            Timeout=2000;

            curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
            curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
            curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
            curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, buffer_size);

            curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buffer);

            curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
            curl_easy_setopt(curl, CURLOPT_TIMEOUT, Timeout);
            curl_easy_setopt(curl, CURLOPT_ERRORBUFFER,errmsg);

            res = curl_easy_perform(curl);
            curl_slist_free_all(headers);
            curl_easy_cleanup(curl);
            fclose(out_fd);
            if(CURLE_OK != res)
            {
                    printf("\nerrorbuf:%s:%d\n",errorbuf,res);
                    return -1;
            }
            return 0;
    }

}

【问题讨论】:

    标签: c linux curl soap wsdl


    【解决方案1】:

    假设您为此请求创建了一个有效的肥皂信封。在您的代码中,您错过了使用 curl 定义 POST 请求。

    curl_easy_setopt(curl, CURLOPT_POST, 1L);
    

    【讨论】:

    • 在代码中添加了以上行,我仍然面临同样的问题。是否有任何其他原因导致此错误。
    猜你喜欢
    • 2016-01-09
    • 1970-01-01
    • 2012-08-12
    • 2016-11-19
    • 1970-01-01
    • 1970-01-01
    • 2018-02-08
    • 1970-01-01
    • 2020-03-15
    相关资源
    最近更新 更多