If SOAP is HTTP independant and REST is HTTP Based then Why? - java

I was just curious , currently the address in my WSDL SOAP File is
<wsdl:port name="MyPort" binding="tns:MyBinding">
<soap:address location="http://localhost:87/SomeMethod"/>
</wsdl:port>
Now since SOAP response is passed along with the HTTP response , Will i have to change the port from 87 to 80 while deploying the service ??
(The reason why i think this should be done because since SOAP is being tagged along with HTTP and HTTP is only available at port 80
I would appreciate it if someone could explain how this would work I know i am wrong here... )
Also Incase of rest i am testing my REST application using
curl http://localhost:6517/JerseyServer/rest/contacts
since REST runs over http ? How is it running over 6517 port ?? Is Tomcat acting as a proxy ? I am using Jersey??

Http is a protocol. You can run it on any available port, it does not have to be 80 but 80 is just the default port used for http.

It is possible to run any service on any port--it's a matter of telling the service/application which port to listen to. 80 is the default port for HTTP. You could run email on ports 12345, HTTP on 443, FTP on 80, and HTTPS on 21... since these are not the default ports for the protocols, you will need to explicitly specify the port to connect to.
As fas mentioned, default ports are just a convention to avoid having to specify what port to go to when visiting google.com (or stackoverflow.com).

Related

Test Soap webservice using jmeter with http request

i have a question for you guys, do you know a way how can i send http request with jmeter to my soap webservice(jax-ws library)?. I have a problem to point server name or ip(its localhost so should it be loopback?) and path. I'm using glassfish4 as my web server. I do not want to use option SOAP/XML RPC Request, because when i use it with my web service i can't see that any data have been sent(it's always 0 -in fact maybe you have idea why is that...it's also a solution to my problem because i need http request to see how much data i've sent)
!https://postimg.org/image/mpbai5n1v/
Thanks in advance
Regards!
Use:
Http Request and fill in:
Server Name or IP
IP if different from 443 or 80
Protocol if https
Add a Header Manager under it with :
Content-Type=text/xml; charset=utf-8
Note there is a template that lets you easily create this, see screenshot:
Finally I suggest you read this tutorial:
http://jmeter.apache.org/usermanual/build-ws-test-plan.html

How to get the real client port via IBM HTTP Server

I just have a jsp file, print
request.getRemoteIp();
request.getRemotePort();
And I can get the real client ip, but the port is always wrong.
The Server Environment is IBM Websphere and IBM HTTP Server (IHS60)
From the iptrace, I get the packet data..
From the Client to Server, the port is 13944 to 80 (http port is 80). So the client port is 13944.
Then via HTTP, in the jsp, I invoke an API on another server, the port is 48186 to 9082.
Actually,
request.getRemoteIp(); I really get the client ip.
but
request.getRemotePort(); I get the port number is 48185, it seems be IHS port.
How can I get my real client port, please?
Thanks very much.

Need a method to pass client IP through my Apache httpd proxy for Tomcat getRemoteAddr() [duplicate]

To obtain the client IP address in my ASP.NET application I've used the X-Forwarded-For, and get the first IP address from the list (accordingly to the information I've found, there is a client, proxy1, proxy2..). But I've heard recently that it is better to get this information from X-Forwarded-IP header because the client IP address in X-Forwarded-For can be modified by proxy, what is the difference, and which one address should I use?
X-Forwarded-For is the conventional way of identifying the originating IP address of the user connecting to the web server coming from either a HTTP proxy, load balancer.
X-Forwarded-IP is the conventional way of identifying the originating IP address of the user connecting to the email server through an HTTP mail service.
X-Forwarded-For is a non-standard header, introduced originally by Squid. It is a proxy- specific header, that helps a server identify the original requestor of a call that did pass-through the proxy - so obviously any proxy on the request path should/will modify X-Forwarded-For. Without proxy on the request path, this header shouldn't even be in the request.
Because this header is non-standard, there is no guarantee you'll get it, and the way it is handled can differ on the proxy implementation. You have no guarantee either that it will contain a proper IP.
Since 2014, the IETF has approved a standard header definition for proxy, called "Forwarded", documented here https://www.rfc-editor.org/rfc/rfc7239 that should be use instead of X-Forwarded headers. This is the one you should use reliably to get originating IP in case your request is handled by a proxy.
In general, the proxy headers (Forwarded or X-Forwarded-For) are the right way to get your client IP only when you are sure they come to you via a proxy. If there is no proxy header or no usable value in, you should default to the REMOTE_ADDR server variable.

java -http post request from port 80 is not working

I have deployed an paypal ipn service on my local machine on port 80.From this ipn service i am hitting another service which on asp.net(iis),but http post data is getting being truncated on reaching the iis server.And if i do the the same from another port except 80,it is working without any issue.I am not getting ,why my http post request data is not reaching there just because of using port 80.

socket closed trying to connect to Axis2 web service deployed on weblogic

I have an application that is using Apache CXF to communicate with Axis2 web service. On the test environment everything went smoothly, moving to the production environment the following exception occurs:
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:466)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:299)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:251)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:75)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
at $Proxy131.retrieveAccountSummary(Unknown Source)
.
.
.
Caused by: java.net.SocketException: Socket Closed
at java.net.PlainSocketImpl.setOption(PlainSocketImpl.java:201)
at java.net.Socket.setTcpNoDelay(Socket.java:850)
at weblogic.net.http.HttpClient.openServer(HttpClient.java:326)
at weblogic.net.http.HttpClient.openServer(HttpClient.java:411)
at weblogic.net.http.HttpClient.New(HttpClient.java:241)
at weblogic.net.http.HttpURLConnection.connect(HttpURLConnection.java:176)
at weblogic.net.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:242)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1836)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1794)
at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42)
at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:70)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1854)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:595)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
... 40 more
as far as I was told, nothing on the network is terminating the connections, and I increased the ConnectionTimeout and the RecievingTimeout from cxf configuration but no use.
Both applications are deployed on weblogic 10.3.2.0 on different servers, I need some guidance on where could the problem be? what could cause a socket to be closed? I don't want to be looking into things that are not related to this problem.
Does this happen after always a fixed duration = connection timeout like 30 or 60 seconds, or is it instantly failing?
If instant, is there established connectivity between both servers, i.e. no firewall or other restrictions in between - does ping or telnet work between both servers?
Is test setup exactly same as Live , i.e. WLS and CXF versions are same?
Also see http://osdir.com/ml/users-cxf-apache/2010-03/msg00407.html
The issue is solved now.
The CXF client was accessing the WSDL without any problems, but in the WSDL the service port address was set to localhost instead of the IP address of the server:
<wsdl:service name="serviceName">
<wsdl:port binding="tns:servicePortBinding" name="servicePort">
<soap:address location="http://localhost:7001/app/services/service/" />
</wsdl:port>
</wsdl:service>
my application was trying to send the requests to localhost and of course a SocketException was the result.
The soap address is set to localhost in the original WSDL, however, when I created Axis2 web service and deployed it on the test environment, the address was getting updated to the machine IP address (which did not happen on the UAT).
I'm not sure how and when the soap address gets updated, but I guess when the machine has more than one network interface, Axis leaves the address as is or maybe updates it to localhost.
Now to fix this issue I had to override the service address as follows:
port = service.getMyServicePort();
BindingProvider provider = (BindingProvider) port;
String endpointAddress = "http://<ip address>:7001/app/services/service/";
provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);

Categories