Announcement Announcement Module
Collapse
No announcement yet.
WebServiceTransportException: Not found [404] Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • WebServiceTransportException: Not found [404]

    I'm using Spring WS 1.5 and am having a problem with my first simple web service that simply sends a first and last name which in turn gets echoed back in a response. When I point the browser to http://localhost:7001/services/name.wsdl the wsdl renders without any problems. However, when I try to call the web service from a client program I get a WebServiceTransportException. I've read all the documentation and looked at the examples but I'm really having a tough go at this and could really use some help. Here is the WebServiceClient class

    public class WebServiceClient {

    private static final String MESSAGE =
    "<NameRequest xlmns=\"http://mycompany.com/hr/schemas\"><FirstName>John</FirstName><LastName>Smith</LastName></NameRequest>";

    private final WebServiceTemplate webServiceTemplate = new WebServiceTemplate();

    // send to an explicit URI
    public void customSendAndReceive() {
    StreamSource source = new StreamSource(new StringReader(MESSAGE));
    StreamResult result = new StreamResult(System.out);
    webServiceTemplate.sendSourceAndReceiveToResult("h ttp://localhost:7001/services/nameService",
    source, result);
    }

    public static void main(String [] args) {
    WebServiceClient client = new WebServiceClient();
    client.customSendAndReceive();
    }

    }


    Here is the ws-servlet.xml:
    <bean id="name" class="org.springframework.ws.wsdl.wsdl11.DefaultW sdl11Definition">
    <property name="schema" ref="schema" />
    <property name="portTypeName" value="NameResource" />
    <property name="locationUri" value="http://localhost:7001/services/nameService" />
    </bean>

    <bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema ">
    <property name="xsd" value="/WEB-INF/schemas/name.xsd"/>
    </bean>

    <bean id="nameEndpoint" class="com.sonybmg.dra.ws.NameEndpoint" />

    <bean class="org.springframework.ws.server.endpoint.mapp ing.PayloadRootQNameEndpointMapping">
    <property name="mappings">
    <props>
    <prop key="{http://mycompany.com/hr/schemas}NameRequest">nameEndpoint</prop>
    </props>
    </property>
    <property name="interceptors">
    <bean class="org.springframework.ws.server.endpoint.inte rceptor.PayloadLoggingInterceptor" />
    </property>
    </bean>



    Here is my EndPoint class:
    public class NameEndpoint extends AbstractJDomPayloadEndpoint {

    private XPath nameExpression;

    public NameEndpoint() throws Exception {
    Namespace namespace = Namespace.getNamespace("hr", "http://mycompany.com/hr/schemas");
    nameExpression = XPath.newInstance("concat(//hr:FirstName,' ',//hr:LastName)");
    nameExpression.addNamespace(namespace);
    }

    protected Element invokeInternal(Element nameRequest) throws Exception {
    String name = nameExpression.valueOf(nameRequest);
    Element responseElement = new Element("NameResponse");
    responseElement.setText(name);
    return responseElement;
    }

    }


    and finally the xsd:
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:hr="http://mycompany.com/hr/schemas" elementFormDefault="qualified"
    targetNamespace="http://mycompany.com/hr/schemas">
    <xs:element name="NameRequest">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="FirstName" type="xs:string" />
    <xs:element name="LastName" type="xs:string" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>

    <xs:element name="NameResponse" type="xs:string" />
    </xs:schema>



    As far as I can tell my NameEnpoint invokeInternal method is never getting called.

    Please Help
    Last edited by [email protected]; Apr 24th, 2008, 06:21 PM.

  • #2
    Could you please post the exception's full stack trace please?

    Comment


    • #3
      Here is the full stack trace:

      Exception in thread "main" org.springframework.ws.client.WebServiceTransportE xception: Not Found [404]
      at org.springframework.ws.client.core.WebServiceTempl ate.handleError(WebServiceTemplate.java:561)
      at org.springframework.ws.client.core.WebServiceTempl ate.doSendAndReceive(WebServiceTemplate.java:489)
      at org.springframework.ws.client.core.WebServiceTempl ate.sendAndReceive(WebServiceTemplate.java:440)
      at org.springframework.ws.client.core.WebServiceTempl ate.doSendAndReceive(WebServiceTemplate.java:395)
      at org.springframework.ws.client.core.WebServiceTempl ate.sendSourceAndReceiveToResult(WebServiceTemplat e.java:341)
      at org.springframework.ws.client.core.WebServiceTempl ate.sendSourceAndReceiveToResult(WebServiceTemplat e.java:326)
      at com.sonybmg.dra.ws.WebServiceClient.customSendAndR eceive(WebServiceClient.java:22)
      at com.sonybmg.dra.ws.WebServiceClient.main(WebServic eClient.java:28)

      Comment


      • #4
        You're getting a 404. Are you sure your web service template is pointing to the correct URI?

        Comment


        • #5
          No I'm not sure I'm pointing to the correct uri. In the WebServiceClient I'm using:

          webServiceTemplate.sendSourceAndReceiveToResult("h ttp://localhost:7001/services/nameService", source, result);

          which is specified in "name" bean in ws-servlet.xml:
          <property name="locationUri" value="http://localhost:7001/services/nameService" />

          What URI should I be using?

          Comment


          • #6
            I figured it out....I had to wrong URI. Forgot to put the app name in the uri :
            http://localhost:7001/{app name}/services/nameService

            Thanks for you help!

            Comment


            • #7
              I have same problem

              Can anyone tells me how this problem is solved because I gonna be crazy

              Comment

              Working...
              X