ServiceStack: Incorrect metadata for SOAP? - soap

I followed the Create your first webservice tutorial. When I go to the Hello Service Soap11 metadata page, I see the following:
POST /xml/reply/Hello HTTP/1.1
Host: localhost
Content-Type: application/xml
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...
</soap:Envelope>
The line POST /xml/reply/Hello HTTP/1.1 seems incorrect. When I use the Postman Rest Client and post to /xml/reply/hello to test the SOAP endpoint. It doesn't work. The response is a 400 Bad Request with a message "Could not deserialize 'application/xml' request..."
Then I change the URL to make the request post to /soap11 instead, it works with status code 200 OK.
This problem happens for the Soap12 metadata page too.
Seems like something is not right with the metadata page generation?

By looking at the code, this does look like a bug.
I have fixed the problem and submitted a pull request to ServiceStack, pending for acceptance.
Pull request: https://github.com/ServiceStack/ServiceStack/pull/389
Update: Pull request has been merged into ServiceStack master branch. Problem solved!

Related

200 with Error body instead of 4xx response from AWS API Gateway

I'm using API Gateway to get access to S3 Bucket through REST API. Everything works as I would expect except when I want to fetch data from a wrong file/folder. Instead of 4xx code I get 200 with Error in the xml format:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>dir/dir2/dir3/file.ext</Key>
<RequestId>XXXX</RequestId>
<HostId>YYYY/J+ZZZZ/XXX/YYYY/ZZZ=</HostId>
</Error>
Is there any way to get non-200 response code? In the documentation there is an example with the NoSuchKey and info about "An appropriate 3xx, 4xx or 5xx HTTP status code"

gSOAP: How to use SOAP instead of POST for specific service/schema

First off, let me apologize, because I don't know much about SOAP and most of what I'm saying is probably nonsense.
I upgraded some client-side code that was generated using gSoap 2.8.4 to gSoap 2.8.93
As far as I can tell, the program only sends one request to the server. Previously this request was wrapped in
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="bmf.gv.at:pkt/PKTSoap" xmlns:ns1="bmf.gv.at:pkt" xmlns:ns3="bmf.gv.at:pkt/PKTSoap12">
<SOAP-ENV:Body>
...
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
However with the code generated by the new version this envelope is missing. I understand that this is because the request is generated as a REST request instead of a SOAP one. I've found threads that talk about the //gsoap directive for the service setting the method-protocol to SOAP instead of POST, but I can only find these directives for requests to the sub-services /PKTSoap and /PKTSoap12, not to the root service bmf.gv.at:pkt, to which the request is sent. In fact that is not even called a service in the code, it's called a schema. And the requests to it are called top-level root elements of the schema. They are all automatically generated as REST requests.
My question is how can I instruct gSoap to generate all requests as SOAP1.1 requests? Any help whatsoever is greatly appreciated.
WSDL: https://pastebin.com/bmC8Hx6M
typemap.dat is the default one with the following appended:
ns1 = "bmf.gv.at:pkt"
ns2 = "bmf.gv.at:pkt/PKTSoap"
ns3 = "bmf.gv.at:pkt/PKTSoap12"
And I use the following commands to generate:
wsdl2h.exe -c -g -N ns %1.wsdl
soapcpp2.exe -c -C -I./import -1 %1.h
It is not clear from your question which request messages do not include the envelope.
Here is a quick way to test the generated source code, to verify that the SOAP1.1 envelope and body are included (I've used C++ here):
wsdl2h -L -g -N ns service.wsdl
soapcpp2 -1 -C -I import service.h
A small demo client, to test the request message:
#include "soapH.h"
#include "PKTSoap.nsmap"
int main()
{
struct soap *soap = soap_new1(SOAP_XML_INDENT);
_ns1__DatenpoolkontoErzeugen req;
_ns1__Verarbeitung res;
req.soap_default(soap);
soap_call___ns2__PKTDatenpoolkontoErzeugen(soap, "http://", NULL, &req, res);
}
Compiled with:
c++ -o service service.cpp soapC.cpp soapClient.cpp stdsoap2.cpp
Then run:
$ ./service
POST / HTTP/1.1
Host:
User-Agent: gSOAP/2.8
Content-Type: text/xml; charset=utf-8
Content-Length: 526
Connection: close
SOAPAction: "bmf.gv.at:pkt/PKTDatenpoolkontoErzeugen"
<?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="bmf.gv.at:pkt/PKTSoap" xmlns:ns1="bmf.gv.at:pkt" xmlns:ns3="bmf.gv.at:pkt/PKTSoap12">
<SOAP-ENV:Body>
<ns1:DatenpoolkontoErzeugen>
<ns1:Absender xsi:nil="true"/>
</ns1:DatenpoolkontoErzeugen>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This shows that bmf.gv.at:pkt requests are sent exactly as specified in the WSDL.

JMeter changing my namespace

I'm trying to use JMeter to invoke a RPC/SOAP Web service and when I invoke the service my namespaces are mangled from the actual values to NS1.
<?xml version="1.0" encoding="UTF-8"?>
<wpc:invoke xmlns:wpc="http://wpc.ibm.com">
<wpc:envelope communicationVersion="5.3">
<wpc:WPCResponseType>asynchronous</wpc:WPCResponseType>
<wpc:wpcHeader>
<wpc:companyName>mycompany</wpc:companyName>
<wpc:wpsUserID>me</wpc:wpsUserID>
<wpc:wpcUserID>wpcUsername</wpc:wpcUserID>
<wpc:password />
<wpc:messageIdentifier>9E2FA100-BE54-11E5-8A91-BF48E24665E0</wpc:messageIdentifier>
<wpc:timestamp>2016-01-18</wpc:timestamp>
<wpc:supplierId><![CDATA[0Z188]]></wpc:supplierId>
<wpc:localeForDisplay>en_US</wpc:localeForDisplay>
<wpc:localeRestriction>en_US</wpc:localeRestriction>
</wpc:wpcHeader>
<wpc:wpcBody>
<wpc:wpcCommand mode="ASYNC" type="UPLOAD">
<wpc:wpcCatalogName>Item Transaction Catalog</wpc:wpcCatalogName>
<wpc:wpcFileDocStorePath>test_data/upload/0003_items.csv</wpc:wpcFileDocStorePath>
<wpc:wpcUpdateOnly>false</wpc:wpcUpdateOnly>
</wpc:wpcCommand>
</wpc:wpcBody>
</wpc:envelope>
</wpc:invoke>
Changes to:
<?xml version="1.0" encoding="UTF-8"?>
<ns1:invoke xmlns:ns1="http://wpc.ibm.com">
<ns1:envelope communicationVersion="5.3">
<ns1:WPCResponseType>asynchronous</ns1:WPCResponseType>
<ns1:wpcHeader>
<ns1:companyName>mycompany</ns1:companyName>
<ns1:wpsUserID>me</ns1:wpsUserID>
<ns1:wpcUserID>wpcUsername</ns1:wpcUserID>
<ns1:password/>
<ns1:messageIdentifier>9E2FA100-BE54-11E5-8A91-BF48E24665E0</ns1:messageIdentifier>
<ns1:timestamp>2016-01-18</ns1:timestamp>
<ns1:supplierId><![CDATA[0Z188]]></ns1:supplierId>
<ns1:localeForDisplay>en_US</ns1:localeForDisplay>
<ns1:localeRestriction>en_US</ns1:localeRestriction>
</ns1:wpcHeader>
<ns1:wpcBody>
<ns1:wpcCommand mode="ASYNC" type="UPLOAD">
<ns1:wpcCatalogName>Item Transaction Catalog</ns1:wpcCatalogName>
<ns1:wpcFileDocStorePath>test_data/upload/0003_items.csv</ns1:wpcFileDocStorePath>
<ns1:wpcUpdateOnly>false</ns1:wpcUpdateOnly>
</ns1:wpcCommand>
</ns1:wpcBody>
</ns1:envelope>
</ns1:invoke>
There must be a setting in JMeter to keep the message from being transformed from my original meaningful namespace to this arbitrary namespace called NS1? When the message is received at the target endpoint it cannot parse the request because of this semantic error.
Any/all replies are appreciated!
MG
JMeter should not change anything in the request body, maybe it is an issues with your web service? Double check the request which is being sent by JMeter using a sniffer tool like Wireshark
In any case try switching to HTTP Request sampler, this is recommended way of sending web service requests (just don't forget to add HTTP Header Manager to send Content-Type and SOAPAction headers).
References:
JMeter User's Manual: Building a SOAP WebService Test Plan
Testing SOAP/REST Web Services Using JMeter

Argument type mismatch using nifi template import API

I am trying to use the import endpoint of the Nifi REST API 1.0. I have exported a template as XML using the UI, and am trying to import it using Postman. The request looks like this:
POST /nifi-api/process-groups/63dcaf98-0158-1000-04da-dd54bbb3a5b8/templates/import HTTP/1.1
Host: localhost:8080
Content-Type: application/xml
Cache-Control: no-cache
Postman-Token: 37a10e8b-b30d-b5c8-4219-ca1ba34f79da
<?xml version="1.0" ?>
<template encoding-version="1.0">
<description></description>
...
</template>
I get 400 error return, with message argument type mismatch. There's nothing very useful in the nifi-user.log:
2016-11-14 14:58:22,164 INFO [NiFi Web Server-327] org.apache.nifi.web.filter.RequestLogger Attempting request for (anonymous) POST http://localhost:8080/nifi-api/process-groups/63dcaf98-0158-1000-04da-dd54bbb3a5b8/templates/import (source ip: 127.0.0.1)
2016-11-14 14:58:22,231 INFO [NiFi Web Server-327] o.a.n.w.a.c.IllegalArgumentExceptionMapper java.lang.IllegalArgumentException: argument type mismatch. Returning Bad Request response.
Any ideas what may be causing this, or how I can debug?
Try wrapping the root template element with another element called templateEntity. Most endpoints in Apache NiFi 1.0.0 wrap the object in question with an entity object to relay relevant details about the object when access is denied for to help promote the multi-tenancy model. This pattern was applied to most endpoints to help with consistency throughout the API.
Also you can get to additional details by enabling debug level logging for
<logger name="org.apache.nifi.web.api.config" level="DEBUG" additivity="false">
in conf/logback.xml.
First you have to upload the template, with the following command ( I use curl):
curl -iv -F template=#Sample_Process_group.xml -X POST http://172.17.0.4:8080/nifi-api/process-groups/2a9c6a0d-015c-1000-dec6-e81122344f7e/templates/upload where the guid is your root Process Group.

wso2 ESB request is truncated

i'm using fresh installation of wso2 esb 4.8.1 with stanalone default configuration.
when i send soap request to my backend (perl service with soap lite), the body of POST request is truncated like this according to tcpdump:
SOAPAction: ""
Content-Type: text/xml
Content-Length: 511
Host: 192.168.11.234:8181
Connection: Keep-Alive
User-Agent: Synapse-PT-HttpComponents-NIO
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="htt
p://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<deleteAccountForHost xmlns="AbcdeHostingPhysicalHostManagerCPanelService">
<host xsi:type="xsd:string">zs000.abcde.net</host>
<user xsi:type="xsd:string">tstauto</user>
</deleteAccountForHost>
</soap:Body>
</soap:Envel
You can see that closing tag '</soap:Envel' is truncated.
But when i enable SOAP-tracer the request body becomes valid.
i use PT transport. I tried to switch transport to the nhttp and this problem seems to be disappeared.
So the question is: how to configure PT transport to avoid such strange behavior?
UPD1:
it seems that the problem occurs only when set the property FORCE_HTTP_1.0 and transport is PT
I got the same problem, but I set DISABLE_CHUNKING.
After many tries I tested that disabling chunking or forcing HTTP 1.0 results in truncated request.
I use WSO2 ESB version 4.8.1, client is SoapUI 5.0.0 or SoapClient from PHP 5.5.11.
When I use "Try this service" in ESB, then request is not truncated.
After switching from HTTP PassThrough Transport to HTTP-NIO Transport service behind endpoint receives complete request, but then I can't download WSDL of tenant.