matt andrews

Greenhorn
+ Follow
since May 16, 2018
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by matt andrews

Hi,

I'm after some best practice / advice.

I have a Spring Boot servlet web service which is called with some HTTP header information.  I need to output this header information in any trace files which are produced by the application.  Tracing is done my log4j2, and I'm after advice as to how to ensure that this header information is available to all classes within the application so it can be included in the logs.

I thought about placing the information into session, and then make this httpSession object available thoughout the application but this seems like overkill.  Are there any other recommended ways to do this?

Cheers
3 months ago

Norm Radder wrote:Sorry, I don't have much experience with that.  Your approach sounds reasonable.  Can try it to see what happens?



Yep. That fixed it!

matt andrews wrote:

Norm Radder wrote:Why does the code exit the loop at line 22 instead of waiting for a -1 at line 15?



I was under the impression that if < 4096 bytes had been returned, everything had been read.  This is how it seems to be working in my test environment.

From what you are saying and how the production environment is also working, it seems I could drop this check and just keep reading the socket buffer until -1 is returned (end of stream).  




I remember now.  The socket doesn't terminate at the server end, so I can't check for a -1.  The only way the look exits is either a timeout, or knowing its read all the information.  

I've look at the data being returned.  There seems to be a size indicator in a header, so I'm now reading that via a DataInputStream and then reading the creating a byte[] for the length (these messages are all under 8k) and using;



I'm hoping that will solve the issue.

Any comments / observations?

Norm Radder wrote:Why does the code exit the loop at line 22 instead of waiting for a -1 at line 15?



I was under the impression that if < 4096 bytes had been returned, everything had been read.  This is how it seems to be working in my test environment.

From what you are saying and how the production environment is also working, it seems I could drop this check and just keep reading the socket buffer until -1 is returned (end of stream).  

Hi,

I am experiencing an issue when reading from a java socket.  

The socket read is working for most reads until a longer message is received.  The received message seems to be truncated at 1460 characters which seems to fit in with the normal MTU size of 1500 bytes (minus 40 bytes for headers).

The code which is performing the read from the socket is below;


The socket timeout is set to 5 seconds, the response form the downstream service returns in approx 0.1 second.

The only change I thought about making was to switch the read() to readFully().  Unfortunately I can't create the issue on my development machine (as is normal!) and the issue one occurs in one environment which I don't have access too.

Other than that does anyone have any other ideas as to what maybe the issue and/or solution?

Many thanks

I'll add some more information.

My wsdl definition only has an endpoint for SOAP 1.2

<wsdl:service name="MyService">
 <wsdl:port name="IMyServicePort" binding="tns:IMyServiceBinding">
   <soap12:address location="http://localhost:8080/MyService/services/IMyServicePort"/>
 </wsdl:port>
</wsdl:service>


The web service beans file contains the following;

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:jaxws="http://cxf.apache.org/jaxws"
   xmlns:soap="http://cxf.apache.org/bindings/soap"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://cxf.apache.org/jaxws
       http://cxf.apache.org/schemas/jaxws.xsd
       http://cxf.apache.org/bindings/soap
       http://cxf.apache.org/schemas/configuration/soap.xsd
       http://www.springframework.org/schema/osgi
       http://www.springframework.org/schema/osgi/spring-osgi.xsd">

 <jaxws:endpoint id="HTTPEndpoint" implementor="#IMyServiceImpl" address="/services/myservice/v1" wsdlLocation="wsdl/MyService.wsdl">

   <jaxws:binding>
     <soap:soapBinding version="1.2" mtomEnabled="true" />
   </jaxws:binding>

   <jaxws:properties>
     <entry key="schema-validation-enabled" value="true" />
     <entry key="jaxb-validation-event-handler">
       <bean class="myservice.MySoapFaultInterceptor" />
     </entry>
   </jaxws:properties>
 </jaxws:endpoint>
</beans>


However, when I browse to the wsdl, I see both SOAP 1.1 and SOAP 1.2 endpoints


<wsdl:service name="MyService">
 <wsdl:port binding="tns:IMyServiceBinding" name="IMyServicePort">
   <soap12:address location="http://localhost:8080/services/services/myservice/v1"/>
 </wsdl:port>
</wsdl:service>
<wsdl:service name="IMyServiceService">
 <wsdl:port binding="tns:IMyServiceSoapBinding" name="IMyServicePort">
   <soap:address location="http://localhost:8080/services/services/myservice/v1"/>
 </wsdl:port>
</wsdl:service>


Annoyingly, there are both defined to be the same endpoint location, so I can't access the SOAP 1.2 endpoint, all requests are rejected with "A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint."


I can get around this by defining the endpoint in Java (although I cannot figure out how to replicate the jaxb-validation-event-handler in Java code!), but I'd rather use XML configuration.

Does anyone have any suggestions to either only generate a SOAP 1.2 endpoint, or seperate out the endpoint locations?
1 year ago
Hi,

I have a WSDL which defines a SOAP 1.2 endpoint.  However, when using Spring boot with Apache CXF the endpoint which is presented to me seems to offer a SOAP 1.1 and SOAP 1.2 endpoint at the same location!  Obviously this is not good and I don't want to the SOAP 1.1 endpoint at all.  Does anyone know how to get rid of it, i.e. only produce the SOAP 1.2 endpoint which is defined in the WSDL.

I've tried using annotations, which didn't work.  I could explicitly set the SOAP version when defining the endpoint configuration in code (which did work), but I'd rather use a bean/jaxws config file as this enables me to add different interceptors and amend the endpoint without amending the code.

Any suggestions / tutorials on the subject are most welcome

Cheers
1 year ago
Many thanks for the suggestion.

Reading up on the technique, it may be just what I require.
1 year ago
Hi,

I'm about to tune a Tomcat middleware server which needs to invoke a downstream call to another provider which takes approx. 100-150 ms to return.  I have a limited pool of downsteam connections.9

Limiting Tomcat connections to 50 and 250 threads, I've managed a load test of approx 60-75 transactions / sec, but surely this could be improved.

I was to gear up the service for maximum throughput and have wondered is anyone has done this before and can offer sggestions on to the server configuration?
1 year ago