curl wsdl soap error - 发送方和接收方之间不匹配的操作

时间:2014-01-31 09:57:28

标签: c linux curl soap wsdl

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

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

请求:          123456789

URL: 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;
    }

}

1 个答案:

答案 0 :(得分:0)

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

curl_easy_setopt(curl, CURLOPT_POST, 1L);