8 Replies Latest reply on Mar 7, 2005 8:49 AM by Pawel Polyakov

    strage problem tcpmon

    Pawel Polyakov Newbie

      Hi all!
      For a couple of days I'm trying to overcome one strange problem:
      I'm trying to create my own simple ws and as example I'm using this guide:
      http://docs.jboss.org/jbossas/getting_started/startguide40/ws.html
      and i hava similar build and similar classpath(if needed I can post'em all). So my jar succesfully deployed on my jboss server, wich is located on a remote intanet host with ip 192.168.0.200/24.
      Deploymet is succesfull cause there are no errors in server.log and I can retrive the wsdl of my ws in browser:
      " http://192.168.0.200:8080/EJB4/HelloBeanService?wsdl"
      So I think that it is successfull :)
      I have created a simple test class of my ws named as in tutorial "WSClient" and here it is:

      
      package ru.zenith.ejb;
      import java.net.URL;
      
      import javax.xml.namespace.QName;
      import javax.xml.rpc.Service;
      import javax.xml.rpc.ServiceFactory;
      
      public class WSClient {
      
       public static void main(String[] args)
       throws Exception
       {
      
       URL url =
       new URL("http://192.168.0.200:8080/EJB4/HelloBeanService?wsdl");
      
       QName qname = new QName("http://interfaces.zenith.ru","HelloBeanService");
      
       ServiceFactory factory = ServiceFactory.newInstance();
       Service service = factory.createService(url, qname);
      
       ru.zenith.interfaces.HelloBeanEndpoint endpoint = (ru.zenith.interfaces.HelloBeanEndpoint)
       service.getPort(ru.zenith.interfaces.HelloBeanEndpoint.class);
      
       String ids = endpoint.hello("lalala");
      
       System.out.println("Message from WS: " + ids);
      
       }
      }
      
      

      Also i have a tcpmon.jar wich is a simple soap-monitor. And now the stranges are started.
      When I start the tcpmon monitor with parameters
      local port = 8080
      remote host = 192.168.0.200
      remote port = 8080
      my client working correctly and I see the stdout message
      Message from WS:Hello,lalala
      but when I'm trying to run my client class without run the tcpmon exception occured:
      Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
       at $Proxy0.hello(Unknown Source)
       at WSClient.main(WSClient.java:37)
      Caused by: java.net.ConnectException: Connection refused: connect
       at java.net.PlainSocketImpl.socketConnect(Native Method)
       at java.net.PlainSocketImpl.doConnect(Unknown Source)
       at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
       at java.net.PlainSocketImpl.connect(Unknown Source)
       at java.net.SocksSocketImpl.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at java.net.Socket.<init>(Unknown Source)
       at java.net.Socket.<init>(Unknown Source)
       at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:135)
       at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:162)
       at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:118)
       at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:73)
       at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:162)
       at org.apache.axis.SimpleChain.invoke(SimpleChain.java:125)
       at org.jboss.webservice.client.ClientEngine.invoke(ClientEngine.java:126)
       at org.apache.axis.client.Call.invokeEngine(Call.java:3039)
       at org.apache.axis.client.Call.invoke(Call.java:3024)
       at org.apache.axis.client.Call.invoke(Call.java:2619)
       at org.apache.axis.client.Call.invoke(Call.java:2524)
       at org.apache.axis.client.Call.invokeInternal(Call.java:1976)
       at org.apache.axis.client.Call.invoke(Call.java:1917)
       at org.jboss.webservice.client.CallImpl.invoke(CallImpl.java:175)
       at org.apache.axis.client.AxisClientProxy.invoke(AxisClientProxy.java:251)
       ... 2 more
      

      If somebody know in what the problem is, please tell me.

        • 1. Re: strage problem tcpmon
          Pawel Polyakov Newbie

          In addition to previous post
          The wsdl file is generated by axis Java2WSDL, and jaxrpc-mapping and webservices.xml are hand written.
          Tcpmon messages:
          client

          POST /EJB4/HelloBeanService HTTP/1.0
          Content-Type: text/xml; charset=utf-8
          Accept: application/soap+xml, application/dime, multipart/related, text/*
          User-Agent: Axis/#axisVersion#
          Host: localhost:8080
          Cache-Control: no-cache
          Pragma: no-cache
          SOAPAction: ""
          Content-Length: 357
          
          <?xml version="1.0" encoding="UTF-8"?>
          <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
           <soapenv:Body>
           <ns1:hello xmlns:ns1="http://interfaces.zenith.ru">
           <in0>lalala</in0>
           </ns1:hello>
           </soapenv:Body>
          </soapenv:Envelope>
          


          server:
          HTTP/1.1 200 OK
          X-Powered-By: Servlet 2.4; Tomcat-5.0.28/JBoss-4.0.0 (build: CVSTag=JBoss_4_0_0 date=200409200418)
          Content-Type: text/xml;charset=utf-8
          Date: Fri, 04 Mar 2005 09:09:32 GMT
          Server: Apache-Coyote/1.1
          Connection: close
          
          <?xml version="1.0" encoding="UTF-8"?>
          <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
           <soapenv:Body>
           <ns1:helloResponse xmlns:ns1="http://interfaces.zenith.ru">
           <helloReturn>Hello, lalala</helloReturn>
           </ns1:helloResponse>
           </soapenv:Body>
          </soapenv:Envelope>
          


          And the exception occured when I,m trying to invoke the hello() method:

          ...
          String ids = endpoint.hello("lalala");
          ...
          




          • 2. Re: strage problem tcpmon
            Pawel Polyakov Newbie

            Ok, I have read all threads in this forum and only one of them (except mine) about the same problem - how to connect wsclient to jboss server on another host?(In other thread there is no answer on that). I understand that my problem is simple but I cant overcome it :(

            • 3. Re: strage problem tcpmon
              Vladimir Kravchenko Newbie

              Hi,

              What service location is specified in your wsdl file?

              I mean this part of wsdl:

               <service name="Hello">
               <port name="HelloPort" binding="tns:HelloBinding">
               <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
               </port>
               </service>
              


              I guess that in your case location is "http://localhost:8080". If yes, you have to correct your wsdl file.




              • 5. Re: strage problem tcpmon
                Pawel Polyakov Newbie

                Yes I can obtain wsdl from

                http://192.168.0.200:8080/EJB4/HelloBeanService?wsdl

                in my browser.
                And this is the part of it:

                <wsdl:service name="HelloBeanService">
                <wsdl:port binding="impl:HelloBeanEndpointSoapBinding" name="HelloBeanEndpoint">
                <wsdlsoap:address location="http://localhost:8080/EJB4/HelloBeanService"/>
                </wsdl:port>
                </wsdl:service>
                


                And in my ejb4.jar this part of wsdl file looks like this:
                 <wsdl:service name="HelloBeanService">
                 <wsdl:port binding="impl:HelloBeanEndpointSoapBinding" name="HelloBeanEndpoint">
                 <wsdlsoap:address location="http://this.value.is.replaced.by.jboss"/>
                 </wsdl:port>
                 </wsdl:service>
                


                As I understand this part of jboss-service.xml has the significant influence on the value of the URL in <wsdlsoap:address location>:
                 <mbean code="org.jboss.web.WebService"
                 name="jboss:service=WebService">
                 <attribute name="Port">8083</attribute>
                 <!-- Should resources and non-EJB classes be downloadable -->
                 <attribute name="DownloadServerClasses">true</attribute>
                 <attribute name="Host">${jboss.bind.address}</attribute>
                 <attribute name="BindAddress">${jboss.bind.address}</attribute>
                 </mbean>
                


                Is it right?

                • 6. Re: strage problem tcpmon
                  Jason Greene Master

                  This looks like your jboss is not bound to localhost. I am going to guess that you had tcpmon running when you started jboss. Jboss by default binds to all ip addresses on port 8080, but if something else has bound localhost:8080, jboss will start fine, and just bind the rest of the addresses (not localhost).

                  Make sure that nothing is running that could be listening on localhost:8080 when you start your system.

                  Optionally, you can configure which address jbossws will rewrite your wsdl to by editing the WebServiceHost parameter in deploy/jboss-ws4ee.sar/META-INF/jboss-service.xml

                  -Jason

                  • 7. Re: strage problem tcpmon
                    Vladimir Kravchenko Newbie

                    But if you want to run your client with tcpmon and without it using the same wsdl, you need additional code in your client to overwrite endpoint specified in wsdl when you are going to send request via tcpmon:

                     // override endpoint address specified in wsdl if proxy is going to be used
                     String proxyPort = System.getProperty("proxy.port");
                     String proxyHost = System.getProperty("proxy.host");
                     if (proxyPort != null && proxyHost != null) {
                     Stub stub = (Stub) endpoint;
                     URL url = new URL(stub.getEndpointAddress());
                     int proxyPortInt = Integer.parseInt(proxyPort);
                     URL proxyUrl = new URL(
                     url.getProtocol(), proxyHost, proxyPortInt, url.getPath());
                     stub.setEndpointAddress(proxyUrl.toString());
                     }
                    
                     // call your web service
                     String ids = endpoint.hello("lalala");
                    


                    After you've done it you can switch your client between proxy (tcpmon) and direct call to the endpoint defined in wsdl using system properties proxy.host and proxy.port.

                    Best regards,
                    Vlad



                    • 8. Re: strage problem tcpmon
                      Pawel Polyakov Newbie

                      thank you all, problem is eliminated