gsoap multiple wsdls but only one proxy class - proxy

I want to use gsoap to access several web services and combine it all into 1 executable. The problem that I have is even though I do wsdl2h on multiple wsdls, and then compile the header using soapcpp2, there is only 1 proxy object generated. Here are the command line parameters that I use:
wsdl2h -o header.h -ttypemap.dat -s http://services.web.com/WebService/Service1.asmx?WSDL http://services.web.com/WebService/Service2.asmx?WSDL
soapcpp2 -pMy -i -wx -C -Igsoap-2.8/gsoap/import header.h
The problem that I get is whenever I try to access services defined in Service2 wsdl, I get exception. "System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction:
The same code that access service on Service2 works if I only compile single wsdl (only compile Service2 wsdl).
Then I check both Service1 and Service2 wsdls. They have the same "targetNamespace". That's why only 1 proxy is created.
My question is: how do I solve this problem? I need to access services on both Service1.wsdl and Service2.wsdl and put them into 1 binary.
I've read gsoap manual & tried several combination on command line parameters of wsdl2h and soapcpp2 but no luck.
Any help is much appreciated.
I use gsoap 2.8.11 btw

This question is quite old, so I'll be very quick just to help random googlers (I found it when googling for solution to the same problem). If more details are needed, just ask.
Anyway, the solution:
Use multiple calls to the wsdl2h using -q parameter (with namespace name provided) and generate unique .h file each time.
Then, call soapcpp2 on each of those header files - this will generate proxy file for each of them, wrapped in namespace declaration.

Related

WHat is the difference between the filename_pb2_grpc.py and the filename_pb2.py files?

From what I understand, the pb2.py file is code from the protoc file and the pb2_grpc.py file is code generated by protoc from the .proto file. But I don't understand what that means. I am very confused, can someone please explain this to me.
Thank you
I have tried to google the question, but I couldn't find anything that I could understand
Both are generated by protoc or python -m grpc_tools.protoc (a Python module that wraps protoc).
A pb2.py file contains the core Protocol Buffer (message) definitions and is created as a result of the --python_out flag being specified.
A pb2_grpc.py file contains the service and rpc (method) definitions and is created as a result of the --grpc_python_out flag being specified.

How to generate API Documentation using openapi-generator?

I'm new to the OpenAPI 3.0.0.
I have successfully created a java client library using an openapi-generator.
But OpenAPI Generator allows the generation of API client libraries (SDK generation), server stubs, documentation. So I want to know is there any commands or steps are available to generate HTML documentation and also to customize the documentation template.
Old question, but for those still bumping into it. OpenApi Generator can do generation of html documentation from your yaml or json definition of your API.
openapi-generator generate -i PathToMyInputDefinitionFile.yaml -g html -o /PathToOutputFolder
Where html is the generator you want to use. Other generators include dynamic-html and html2. Also can emit as markdown. See https://openapi-generator.tech/docs/generators/
If using Docker, a full example would look like this:
docker run --rm -v ${PWD}:/local openapitools/openapi-generator:tagname generate -i /local/input.yaml -g html -o /local
PWD is present working directory (current directory) in the host, which you are mapping on to /local in the container. Adjust 'tagname' to suit, from https://hub.docker.com/r/openapitools/openapi-generator/tags Adjust input.yaml to be your input file yaml definition of your API.

Swift and terminal: Using Google Endpoints in an iOS Client

I am following the tutorial at
https://cloud.google.com/appengine/docs/java/endpoints/calling-from-ios
and when I get to step 5 and Open a new Terminal window to invoke ServiceGenerator. I get the error message in my terminal saying..
Barrys-MacBook-Pro:~ barrymadej$ /Users/barrymadej/Library/Developer/Xcode/DerivedData/ServiceGenerator-avaeguyitgyhxpcnaejpgzvxezei/Build/Products/Debug/ServiceGenerator \
/Users/barrymadej/Documents/AndroidStudioProjects/StudentProgressTrackerDatabaseAndCloud/backend/build/discovery-docs/myApi-v2-rpc.discovery /
ERROR: An output directory is required.
Usage: ServiceGenerator [FLAGS] [ARGS]
Required Flags:
--outputDir PATH
The destination directory for writing the generated files.
Optional Flags:
--discoveryService URL
Instead of discovery's default URL, use the specified URL as the
location to send the JSON-RPC requests. This is useful for running
against a custom or prerelease server.
--gtlFrameworkName NAME
Will generate sources that include GTL's headers as if they are in a
framework with the given name. If you are using GTL via CocoaPods,
you'll likely want to pass "GoogleAPIClient" as the value for this.
--apiLogDir DIR
Write out a file into DIR for each JSON API description processed. These
can be useful for reporting bugs if generation fails with an error.
--httpLogDir PATH
Turn on the HTTP fetcher logging and set it to write to PATH. This can
be useful for diagnosing errors on discovery fetches.
--generatePreferred
Causes the list of services to be collected, and all preferred services
to be generated.
--httpHeader NAME:VALUE
Causes the given NAME/VALUE pair to be added as an HTTP header on *all*
HTTP requests made by the generator. Can be used repeatedly to provide
additional header pairs.
--formattedName SERVICE:VERSION=NAME
Causes the given SERVICE:VERSION pair to override its service name in
files, classes, etc. with NAME. If :VERSION is omitted the override is
for any version of the service. Can be used repeatedly to provide
several maps when generating a few things in a single run.
--addServiceNameDir yes|no Default: no
Causes the generator to add a directory with the service name in the
outputDir for the files. This is useful for generating multiple
services.
--generatedDir yes|no Default: no
Causes a directory in outputDir called "Generated" to be created and
used to contain the generated files.
--removeUnknownFiles yes|no Default: no
By default, the generator will report unknown files in the output
directory, as commonly happens when classes go away in a new API
version. This option causes the generator to also remove the unknown
files.
--rootURLOverrides yes|no Default: yes
Causes any API root URL for a Google sandbox server to be replaced with
the googleapis.com root instead.
--verbose
Generate more verbose output. Can be used more than once.
Arguments:
Multiple arguments can be given on the command line.
service:version
The description of the given [service]/[version] pair is fetched and the
files for it are generated. When using --generatePreferred version can
be '-' to skip generating the name service.
http[s]://url/to/rpc_description_json
A URL to download containing the description of a service to generate.
path/to/rpc_description.json
The path to a text file containing the description of a service to
generate.
ServiceGenerator path:
/Users/barrymadej/Library/Developer/Xcode/DerivedData/ServiceGenerator-avaeguyitgyhxpcnaejpgzvxezei/Build/Products/Debug/ServiceGenerator
ERROR: There was one or more errors; check the full output for details.
Barrys-MacBook-Pro:~ barrymadej$ --outputDir
-bash: --outputDir: command not found
Barrys-MacBook-Pro:~ barrymadej$ /Users/barrymadej/Documents/AndroidStudioProjects/StudentProgressTrackerDatabaseAndCloud/API
You should generate a REST discovery document and use the new Objective C client instead. The client library you're trying to use is deprecated anyway. It looks like it didn't work because you specified the flag without the rest of the command, though.

protoc not generating service stub files

I have just started playing with google proto. When I try to compile proto file present in proto-java example, it does not generate any grpc file.
proto file,
https://github.com/grpc/grpc-java/blob/master/examples/src/main/proto/hello_world.proto
terminal output,
rsonkhla#raman-OptiPlex-9020:~/sandbox/grpc-java/examples$ protoc
--version libprotoc 3.0.0 rsonkhla#raman-OptiPlex-9020:~/sandbox/grpc-java/examples$ protoc
--java_out=test/ -I../../grpc-java/examples ../../grpc-java/examples/src/main/proto/hello_world.proto
rsonkhla#raman-OptiPlex-9020:~/sandbox/grpc-java/examples$ ls -R test/
test/: io
test/io: grpc
test/io/grpc: examples
test/io/grpc/examples: helloworld
test/io/grpc/examples/helloworld: HelloRequest.java
HelloResponse.java HelloWorldProto.java
HelloRequestOrBuilder.java HelloResponseOrBuilder.java
Has anybody else faced this issue?
The command line you are showing does not enable the grpc plugin. You need to specify an _out argument for the grpc plugin, which enables the plugin and specifies where it should output files. Since the plugin is likely not in your PATH, you also need to tell protoc how to find the plugin with --plugin.
So you need to add two arguments:
--plugin=protoc-gen-grpc-java=path/to/protoc-gen-grpc-java --grpc-java_out=path/to/output/dir
For more info, see the gRPC compiler documentation.
You can add these option to your .proto (base on your language) to generate abstract services:
option cc_generic_services = true;
option java_generic_services = true;
option py_generic_services = true;
You can also add --plugin=EXECUTABLE option in your protoc cmd to use custom code generator plugin to generate code more specific to each system, rather than rely on the "abstract" services. Just like Eric's suggestion.

soapcpp2 can't generate soapClient.c file

I am trying to build a tr069 client using gsoap. I followed the instructions in the document but I could not get soapClient.c.
Here is the steps:
wsdl2h -c -o tr069.h cwmp-1-1.xsd --> this generate tr069.h
soapcpp2 -c tr069.h --> this only generates the following file:
ns1.nsmap, soapC.c soapH.h soapStub.h
According to the examples online and in the document, I am suppose to get file like soapClient.c
Does anyone knows why? I am using gsoap 2.8
Thanks.
The cwmp-1-1.xsd is only an XSD file. You do not have a WSDL defining the operations that normally are stored in soapClient.c. However, you can still use the XML root element serializers (see bottom part of tr069.h for instructions) over sockets etc.

Resources