Announcement Announcement Module
Collapse
No announcement yet.
404 error with client Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 404 error with client

    I am trying to write a client for an existing service. I have validated that the service works with SOAP UI and I can hit the service with the URL I have and get a valid response.

    Here is the code I have so far (note this is just trial code to see if I can get it to work)

    Code:
    		this.wsTemplate = new WebServiceTemplate();
    
    		try {
    			InputStream in = this.getClass().getResourceAsStream("samplemsg.xml");
    			StreamSource src = new StreamSource(in);
    			StreamResult res = new StreamResult(System.out);
    			this.wsTemplate.sendSourceAndReceiveToResult("http://datasvcs.dev.railinc.com:80/findusrailws/services/ContactService", src, res);
    
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    The samplemsg.xml has a valid XML request (the same one I used in SOAP UI to test the service.

    When I try to make the request I get the following error (complete log output):
    Code:
    [2008-07-15 13:20:54,161] INFO     0[main] - org.springframework.ws.soap.saaj.SaajSoapMessageFactory.afterPropertiesSet(SaajSoapMessageFactory.java:107) - Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
    [2008-07-15 13:20:54,161]DEBUG     0[main] - org.springframework.ws.soap.saaj.SaajSoapMessageFactory.afterPropertiesSet(SaajSoapMessageFactory.java:135) - Using MessageFactory class [com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl]
    [2008-07-15 13:20:54,239]DEBUG    78[main] - org.springframework.ws.client.support.WebServiceAccessor.createConnection(WebServiceAccessor.java:110) - Opening [org.springframework.ws.transport.http.HttpUrlConnection@12cc95d] to [http://datasvcs.dev.railinc.com:80/findusrailws/services/ContactService]
    [2008-07-15 13:20:54,755]DEBUG   594[main] - org.springframework.ws.client.core.WebServiceTemplate.sendRequest(WebServiceTemplate.java:547) - Sent request [SaajSoapMessage]
    [2008-07-15 13:20:54,896]DEBUG   735[main] - org.springframework.ws.client.core.WebServiceTemplate.handleError(WebServiceTemplate.java:588) - Received error for request [SaajSoapMessage]
    org.springframework.ws.client.WebServiceTransportException: Not Found [404]
    	at org.springframework.ws.client.core.WebServiceTemplate.handleError(WebServiceTemplate.java:590)
    	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:514)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:465)
    	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:420)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:366)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:351)
    	at com.railinc.notifserv.services.findusrail.impl.FindUsRailContactServiceImpl.getFindUsRailContacts(FindUsRailContactServiceImpl.java:31)
    	at com.railinc.notifserv.services.findusrail.impl.FindUsRailContactServiceImplTest.testGetFindUsRailContacts(FindUsRailContactServiceImplTest.java:9)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at junit.framework.TestCase.runTest(TestCase.java:154)
    	at junit.framework.TestCase.runBare(TestCase.java:127)
    	at junit.framework.TestResult$1.protect(TestResult.java:106)
    	at junit.framework.TestResult.runProtected(TestResult.java:124)
    	at junit.framework.TestResult.run(TestResult.java:109)
    	at junit.framework.TestCase.run(TestCase.java:118)
    	at junit.framework.TestSuite.runTest(TestSuite.java:208)
    	at junit.framework.TestSuite.run(TestSuite.java:203)
    	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Note this web service is not a spring based web service and is hosted on Web Sphere, but the service is definitely accessible from my box using SOAP UI, so why am I getting a 404?

    Thanks,

    John

  • #2
    NEVERMIND

    Sorry to waste everyone's time

    When I stripped off the soap envelope for my samplemsg.xml, I also stripped off my namespace declarations, once I added the namespace declarations to my document root everything works . Weird that you get an error like 404, but I guess it is somehow trying to resolve the namespace and failing.

    Sorry again for the post

    Comment


    • #3
      Solution

      Thank you for your "NEVERMIND" note; it actually helped me.
      I had the same problem, and solved it by adding the namespace to my request:

      Innitially I was creating my root element without the "http://jfcc.subastas/schemas" namespace, added it, and voilá, it worked perfectly!

      I hope this can help others with the same problem.

      Code:
          Element authRequest     = new Element("AuthRequest", "http://jfcc.subastas/schemas");
          Element userIdElement   = new Element("userId").setText(userId);
          Element passwordElement = new Element("password").setText(password);
          Element userIPElement   = new Element("userIP").setText(userIP);
          authRequest.addContent(userIdElement);
          authRequest.addContent(passwordElement);
          authRequest.addContent(userIPElement);
          
          Source source = new JDOMSource(authRequest);
          JDOMResult result = new JDOMResult();
      
          WebServiceTemplate webServiceTemplate = (WebServiceTemplate) ServicesContextManager.getApplicationContext().getBean("webServiceTemplate");
          logger.debug("####################" + webServiceTemplate.getDefaultUri());
          webServiceTemplate.sendSourceAndReceiveToResult(source, result);
          String status = result.getDocument().getRootElement().getChildText("status");

      Comment


      • #4
        Can someone post samplemsg.xml

        I am having exactly the same problem. Could someone post the samplemsg.xml the original person was talking about.
        cheers - kalyan

        Comment

        Working...
        X