2011-04-29 5 views
1

나는 아래의 코드를 사용하여 salesforce.com API에 액세스하기 위해 C++에서 클라이언트를 gSoap를 사용하려고 시도하고있다 : 문제가 아니라 언제 실행하지 않고gSoap : HTTP 헤더, 콘텐츠 길이 : 0

struct soap soap; 

soap_init(&soap); 

_ns1__login loginReq; 
_ns1__loginResponse loginRes; 

loginReq.username = "XXXX"; 
loginReq.password = "XXXX"; 

if(soap_call___ns1__login(&soap,NULL,NULL,&loginReq,&loginRes) == 0){ 
    qDebug() << loginRes.result->sessionId; 
} else { 
    soap_print_fault(&soap, stderr); 
    soap_print_fault_location(&soap, stderr); 
} 

이 준수를 다음과 같은 오류 발생 : 나는 패킷 캡처를 실행 한

SOAP 1.1 fault: SOAP-ENV:Client [no subcode] 
"Validation constraint violation: tag name or namespace mismatch in element <soapenv:Envelope>" 
Detail: [no detail] 
HTTP/1.1 500 Internal Server Error 
Server: 
Content-Type: text/xml; charset=UTF-8 
Content-Length: 625 
Date: Fri, 29 Apr 2011 00:56:17 GMT 
Connection: close 

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><faultcode>UNKNOWN_EXCEPTION</faultcode><faultstring>UNKNOWN_EXCEPTION: Premature end of file.</faultstring><detail><sf:UnexpectedErrorFault xsi:type="sf:UnexpectedErrorFault"><sf:exceptionCode>UNKNOWN_EXCEPTION</sf:exceptionCode><sf:exceptionMessage>Premature end of file.</sf:exceptionMessage></sf:UnexpectedErrorFault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope> 
<!-- ** HERE ** --> 

를 모든 것이 0 HTTP 헤더에 '콘텐츠 길이'를 제외하고 올바른 모습을 보여줍니다

POST /services/Soap/c/21.0 HTTP/1.1 
Host: login.salesforce.com 
User-Agent: gSOAP/2.7 
Content-Type: text/xml; charset=utf-8 
Content-Length: 0 
Connection: close 
SOAPAction: "" 

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="urn:sobject.enterprise.soap.sforce.com" xmlns:ns3="urn:fault.enterprise.soap.sforce.com" xmlns:ns1="urn:enterprise.soap.sforce.com"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><ns1:login><ns1:username>XXXX</ns1:username><ns1:password>XXXX</ns1:password></ns1:login></SOAP-ENV:Body></SOAP-ENV:Envelope> 

누군가 내가 잘못 가고 있다는 것에 대한 통찰력이 있다면 크게 감사하겠습니다.

데비안 6.0에서 g ++ 4.4.5를 사용하여 gSoap 2.7을 사용하고 있는데, 이것이 도움이된다면 컴파일해야합니다.

+0

이상하게 들릴지 모르겠지만 VC++, gSOAP 및 salesforce.com에서 작동하는 단서를 찾으려고합니다. 괜찮 으면 몇 가지 서류를 보여 주시겠습니까? –

답변

1

제공 한 패킷 캡처에서 관찰해야 할 또 다른 핵심 사항이 있습니다. SOAPAction 필드가 비어 있습니다. 올바르게 SOAP 조치 있었던 파라미터를 지정하는 경우

POST /ws/smi/v1/IndexService HTTP/1.1 
Host: somevalidwebservice.com 
User-Agent: gSOAP/2.8 
Content-Type: text/xml; charset=utf-8 
Content-Length: 1180 
Connection: close 
SOAPAction: "http://www.somevalidwebservice.com/ws/smi/v1/getIndex" 

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:ns1="http://www.somevalidwebservice.com/ws/smi/v1" 
<SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><nsGlobal:getIndexRequest></nsGlobal:getIndexRequest> 

당신이 확인할 수 있습니다 여기에

내 응용 프로그램의 샘플 패킷 캡처입니까?

+1

SOAPAction은 비어있을 수 있습니다. http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528 – wimh

+0

패킷 캡처를 복사하고 내용 길이를 손으로 변경 한 다음 socat을 사용하여 서버로 보냈습니다. 이것은 예상 된 응답을 되 돌 렸기 때문에 문제가 단지 제출 된 content-length 헤더와 관련이 있다고 가정하는 것이 안전하다고 생각합니다. –

2

이것은 아주 오래된 질문이지만, 최근에 같은 문제가있었습니다. 나를 위해 문제는 내가 C + + 코드와 C 코드를 혼합했다. stdsoap2.cpp 대신 stdsoap2.c를 컴파일했는데 어떤 이유로 이것이 content-length에 대해 올바른 수를 만들지 못하게했습니다. 올바른 오브젝트를 만들고 다시 링크하면 솔루션은 완벽하게 작동합니다.