How to call SOAP Webservice with security header in blackberry 10 Cascading C /QML? - blackberry-10

I am new to BB 10 Cascade.
I need to call SOAP webservice with security header.
How to use qtsoap ?
Thanks in advance.

If your question is how to add the security header to a QtSOAP request, you can do it this way:
On your QNetworkRequest, set the header with void QNetworkRequest::setRawHeader(const QByteArray& headerName, const QByteArray& headerValue), which will give something like this: request.setRawHeader("wsse:Security", "yourHeaderValue");
Send your request with void QtSoapHttpTransport::submitRequest(QNetworkRequest& networkReq, QtSoapMessage& request, const QString& path)

Related

Spring Cloud Gateway Routing Based On Content of the Request Body

I need to create a reverse proxy that takes incoming request and based on the content of the request body, route the request to specific URI.
This is for a routing micro service that acts like a reverse proxy and does routing based on some information from each request body. This means for each request I need to parse the request body and get the "username" field and then make a JDBC connection to fetch additional information from the database. Based on that information in database, it would finally redirect the request to the correct URI.
From what I have now, I have 2 blocking methods. The first one is the parsing for the request body, the other one is the JDBC connection to the database. I understand that I should not put any blocking calls inside the gateway filter. I just don't know what I should do in this case. I could have both operations running async but in the end I still need the information from database to do routing.
#Bean
public RouteLocator apiLocator(RouteLocatorBuilder builder, XmlMapper xmlMapper) {
return builder.routes()
.route(r -> r
.path("/test")
.and()
.readBody(String.class, s -> true) // Read the request body, data will be cached as cachedRequestBodyObject
.filters(f -> f.filter(new GatewayFilter() {
#Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
try {
// The following method is blocking and should not be put here
xmlMapper.readValue((String) exchange.getAttribute("cachedRequestBodyObject"), Map.class);
} catch (Exception e) {
//TODO
}
return chain.filter(exchange);
}
}))
.uri("http://localhost:8080"))
.build();
}
The above example only includes the blocking parsing as my request body is XML based. My IDE is warning me of having a blocking call there which I really appreciate.
Any help is greatly appreciated. Thank you everyone!
After some research, Mono.fromCallable seems to be a good fit. I then asked the same question directly under the github repo, it turns out that using a servlet app may be better. For anyone who is interested to see what I came up with, please take a look here https://github.com/spring-cloud/spring-cloud-gateway/issues/1229

Require JSON data in API request

I am working on RESTful API in CakePHP 3 and I need to force that data and request Content-Type is application/json and not application/x-www-form-urlencoded. How to accomplish it?
You could add in your AppController.php in the beforeFilter
public function beforeFilter(event $event) {
$this->request->params['_ext'] = 'json';
}
That way you will treat every incomming request as it was done with the .json extension, That might set you of into the right direction

WSO2 Getting POST PUT DELETE REST parameters

Is there a way to get the parameters set in a post-delete-put REST request? in a proxy or programmatically developing a mediator (i mean in the MessageContext object passed to the mediate method)?
I know that parameters are appended to the url in a GET request e they appear by
getProperty("REST_URL_POSTFIX");
What about the other CRUD commands?
To get programatically, you can retrive those details from Axis2 messagecontext.
HttpServletRequest obj = (HttpServletRequest)
msgContext.getProperty("transport.http.servletRequest");
System.out.println("Method :" + obj.getMethod());
Here is a detail post

adding http headers in call to SoapHttpClient service

I have to consume a service provided by one of our partners. I was given little direction, but was told the security was to be PasswordDigest. I looked it up and immediatly saw lots of references to WSE, so off I went. It was very easy to implement and in no time I had a standard WSE user token using PasswordDigest sitting in the SOAP headers of my messages.
When we started testing today I was immediatly told (by the error message) that things weren't right. Turns out, out partner doesn't look in the SOAP header, but rather wants the security info in the http header.
I have seen lots of articles on how to add custom http headers to a proxy class, but my proxy inherits from SoapHttpClientProtocol which doesn't have a headers collection to add to. I was looking at making a raw httpWebRequest, but I have a specific method to access that has some complex parameters to deal with (and besides it feels like going backwords).
What is the best way to add custom http headers to a service proxy class that doesn't have a GetWebRequest method?
For reference:
Proxy class decleration:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="MtomServiceSoap11", namespace="http://ws.xxxxxxx.com/")]
public partial class MtomServiceService : System.Web.Services.Protocols.SoapHttpClientProtocol {
Target method I need to call:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("uploadDocumentResponse", Namespace="http://ws.edsmtom.citizensfla.com/")]
public uploadDocumentResponse uploadDocument([System.Xml.Serialization.XmlElementAttribute(Namespace="http://ws.xxxxxxx.com/")] uploadDocumentRequest uploadDocumentRequest) {
object[] results = this.Invoke("uploadDocument", new object[] {
uploadDocumentRequest});
return ((uploadDocumentResponse)(results[0]));
}
}
The actual call to the Service is simple. The objects being pass in are not:
request.criteria = docCriteria;
request.document = document;
var result = service.uploadDocument(request);
Thanks.
It figures that 30 minutes after posting I would stumble across the answer. While the proxy class decelaration does not create a GetWebRequest method, its base class System.Web.Services.Protocols.SoapHttpClientProtocol has it and it can be overridden.
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
var request = base.GetWebRequest(uri);
request.Headers.Add("blah", "blah"); // <----
return request;
}

webserver goahead header question

I'm writing a small web API routine using webserver Goahead.
What's the API to be used to get the Http header information.
Please help.
Please be specific to your question. I am using GoAhead for my Embedded Web Server.
You need to define the form like below to handle the subit methods (Get/POST)
void formSetLoopCode (webs_t wp, char_t *path, char_t *query)
{
a_assert (wp);
int opt,port;
opt = gatoi (websGetVar (wp, "opt", "1"));
port = gatoi (websGetVar (wp, "port", "1"));
}
The header information is converted into variables that are retrieved using websGetVar.