Can we override wsa:To value in SOAP 1.2 - soap

I want to override wsa:To element value in SOAP 1.2 message. Can I do this by adding "To" HTTP header to the request ?
Could you explain the use of this wsa:To element value on the SOAP 1.2 message header ?

No. wsa:To is a SOAP header block, not an HTTP header.

Related

Akka-HTTP: how to know if Content-type header was explicitly set in received response

Is the a way in akka-http to know if 'Content-type' header was explicitly set in HttpResponse that we received?
From sniffed Http dump I see, that there was no 'Content-Type' header, but
httpResponse.header[`Content-Type`].get.contentType.mediaType.toString()
and
httpResponse.entity.getContentType().mediaType.toString
stil return application/octet-stream.
This is default Content type not only for Akka-HTTP, but perhaps for other frameworks like Play too. Akka-http and other HTTP based technologies need to know how to parse content internally, based on this header. application/octet-stream means that it considers request body as just byte-stream.
Rule of thumb: if it is possible - try to specify Content-type.

SOAP message without header - how to process?

I've tried web search to find answer to my question but found only articles like how to create SOAP message without header.
In wikipedia on SOAP:
SOAP header : A collection of one or more header blocks targeted at
each SOAP receiver. SOAP body : Contains the body of the message
intended for the SOAP receiver. The interpretation and processing of
SOAP body is defined by header blocks.
And:
A SOAP message is an ordinary XML document containing the following
elements:
Element - Required
Header - No
Body - Yes
...
How can be a message without header if processing of body is defined in header?
The SOAP header is optional. If a header is required, it is mainly mentioned in the WSDL file, that is bound to the webservice. The WSDL defines the functions of a webservice and the types, that are bound to the functions. It depends on how a function is defined. Some definitions need an action attribute in the soap header. Others are used by directly mentioning them in the SOAP Body. To keep it short: how a SOAP message should look like is more or less strictly defined in the webservice definition (wsdl).

Soap Webservice Response validation using citrus framework

I am trying to validate the payload response came from the server,
soap()
.server(todoServer)
.send()
.payload(new ClassPathResource("templates/getTodoListResponse.xml"));
Is there a way todo a field level validation like below using SoapActionBuilder,
http()
.client(todoClient)
.receive()
.response(HttpStatus.OK)
.validate("/t:todo/t:id", "${todoId}")
.validate("/t:todo/t:title", "${todoName}")
.validate("/t:todo/t:description", "${todoDescription}")
.validate("/t:todo/t:done", "false");
The SoapActionBuilder is also able to use XPath element validation.
soap()
.client(todoClient)
.receive()
.validate("/t:todo/t:id", "${todoId}")
.validate("/t:todo/t:title", "${todoName}")
.validate("/t:todo/t:description", "${todoDescription}")
.validate("/t:todo/t:done", "false");
Notice that the SOAP envelope is automatically handled in the Citrus client. So your XPath expression is able to use the payload root element as root base path for the expression. You can also tell Citrus to not automatically handle the SOAP envelope. Then your XPath expression need to use the SOAP-ENV:Envelope as root element.

Remove charset in Content-Type header in Citrus

I'm using v2.6.2 of the Citrus Framework to write automated tests for a rest end point using the http module. Citrus is appending charset=UTF-8 to the Content-Type header. The server is responding 415 Unsupported Media due to the charset being present.
I cannot modify the rest end point.
Can I configure Citrus and the http module to not append the charset?
This was related to Citrus Http message converter always adding the default charset "UTF-8"which is set as attribute on the citrus-http:client component. So you need to overwrite the Content-Type explicitly in each send operation in order to not add the default charset.
Since Citrus 2.7.2 you can set the charset on the citrus-http:client component to an empty string. This fixes the charset appendix.

Define Guzzle Content-Length

I am trying to send a request with a content length set by myself and not by guzzle. ( guzzle 6)
$res = $client->request('POST', $url, ['headers' => ['Content-Length' => 32]];
However this stops the request from sending !
I am doing this because my URL has a query string and i need the content length to be set. Not doing so sets a Content-Length: 0 by guzzle - how can i define all headers and stop guzzle from doing this?
Regards
Your code works perfectly with Guzzle (just add a missed bracket in the end ;).
You probably get an exception, but it's because the server responds with 413 Request entity too large, and Guzzle converts it to exception (see http_errors to control this behaviour). Because you don't provide the request body at all.
Anyway, I don't get it, how the query string is connected to Content-Length header. The header defined length of the request body, but the query string is not a part of the body, so there is no connection.