简体   繁体   中英

C++ gSOAP File generation

It's looking like gSoap "forgot" to generate a lot of stuff. I used

wsdl2h.exe -o NumOpsService.h http://192.168.2.113/numops.wsdl
soapcpp2.exe -x -l -I..\..\import -C NumOpsService.h

And both run through without errors or warnings. When I include the files into my project, it turns out several functions have been declared in soapH.h but the respective implementation which should be located in soapC.cpp is missing.

The following functions are missing:

SOAP_FMAC3 void SOAP_FMAC4 soap_markelement(struct soap*, const void*, int);
SOAP_FMAC3 int SOAP_FMAC4 soap_putelement(struct soap*, const void*, const char*, int, int);
SOAP_FMAC3 void *SOAP_FMAC4 soap_getelement(struct soap*, int*);
SOAP_FMAC3 int SOAP_FMAC4 soap_putindependent(struct soap*);
SOAP_FMAC3 int SOAP_FMAC4 soap_getindependent(struct soap*);
SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap*);
SOAP_FMAC3 void * SOAP_FMAC4 soap_instantiate(struct soap*, int, const char*, const char*, size_t*);
SOAP_FMAC3 int SOAP_FMAC4 soap_fdelete(struct soap_clist*);
SOAP_FMAC3 void* SOAP_FMAC4 soap_class_id_enter(struct soap*, const char*, void*, int, size_t, const char*, const char*);
SOAP_FMAC3 void* SOAP_FMAC4 soap_container_id_forward(struct soap*, const char*, void*, size_t, int, int, size_t, unsigned int);
SOAP_FMAC3 void SOAP_FMAC4 soap_container_insert(struct soap*, int, int, void*, size_t, const void*, size_t);

How can this happen? Is it a problem with the numops.wsdl file? The file I'm using to generate looks like this:

<definitions name="NumOps"
    targetNamespace="http://192.168.2.113/numops.wsdl"
    xmlns:tns="http://192.168.2.113/numops.wsdl"
    xmlns:xsd1="http://192.168.2.113/testtypes.xsd"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns="http://schemas.xmlsoap.org/wsdl/">

<types>
    <schema targetNamespace="http://192.168.2.113/testtypes.xsd"
        xmlns="http://www.w3.org/2001/XMLSchema">
        <element name="AddValRequest">
            <complexType>
                <all>
                    <element name="fVal1" type="float"/>
                    <element name="fVal2" type="float"/>
                </all>
            </complexType>
        </element>
        <element name="AddValResponse">
            <complexType>
                <all>
                    <element name="fResult" type="float"/>
                </all>
            </complexType>
        </element>
    </schema>
</types>

<message name="AddValInput">
    <part name="body" element="xsd1:AddValRequest"/>
</message>
<message name="AddValOutput">
    <part name="body" element="xsd1:AddValResponse"/>
</message>

<portType name="NumOpsPortType">
    <operation name="AddVal">
        <input message="tns:AddValInput"/>
        <output message="tns:AddValOutput"/>
    </operation>
</portType>

<binding name="NumOpsSoapProxy" type="tns:NumOpsPortType">
    <soap:binding style="document"
        transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="AddVal">
        <soap:operation soapAction="http://192.168.2.113/index.php"/>
        <input>
            <soap:body use="literal"/>
        </input>
        <output>
            <soap:body use="literal"/>
        </output>
    </operation>
</binding>

<service name="NumOpsService">
    <port name="NumOpsPort" binding="tns:NumOpsSoapProxy">
        <soap:address location="http://192.168.2.113/index.php"/>
    </port>
</service>

</definitions>

I'm new to gSOAP, the documentation unfortunately is not that excessive, and noone on the internet seems to have had this problem before, or maybe I'm looking in the wrong direction.

I've included all files generated (except for NumOpsService.h ) into my project and also added stdsoap2.h and stdsoap2.cpp . The source that won't compile because of the missing functions looks like this:

#include <stdio.h>
#include "NumOpsSoapProxy.nsmap"
#include "soapNumOpsSoapProxyProxy.h"

int main() {
    NumOpsSoapProxy proxy;
    _ns2__AddValRequest  request;
    _ns2__AddValResponse response;

    request.fVal1 = 10;
    request.fVal2 = 20;

    if(proxy.__ns1__AddVal(&request, &response) == SOAP_OK) {
        printf("%d + %d = %d\n", request.fVal1, request.fVal2, response.fResult);
    }
    else {
        printf("Request failed.\n");
    }
}

My comment promoted to an answer:

In your soapcpp2 command line you have used -l, the letter, which generates linkable modules (experimental) when you should have used to use -1 (the number) to use SOAP 1.1 namespaces and encodings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM