Announcement Announcement Module
Collapse
No announcement yet.
Problem Getting Static Content Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem Getting Static Content

    I'm trying to access static content through the MessageDispatcherServlet, but not having any luck. I followed the echo example and placed an index.html under my project directory and added the welcome-file-list in my web.xml. When I try and access (http://localhost:9999/my-app-ws/index.html) the page, I get an "HTTP 405 - Resource not allowed" error. Is there a configuration that I'm missing?

    Here's the HTTP that's getting sent

    Code:
    GET /my-app-ws/index.html HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
    Accept-Language: en-us
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1; .NET CLR 1.1.4322)
    Host: localhost:9999
    Connection: Keep-Alive
    Here's the response

    Code:
    HTTP/1.1 405 Method Not Allowed
    Date: Tue, 03 Jul 2007 17:09:41 GMT
    Server: WebLogic Server 8.1 SP3 Tue Jun 29 23:11:19 PDT 2004 404973 
    Content-Length: 0

  • #2
    If you have same servlet mapping as web.xml included in Echo sample:
    <servlet-mapping>
    <servlet-name>spring-ws</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>
    then all requests will be processed by spring-ws which doesn't take .../index.html

    Comment


    • #3
      I see in the code where it only excepts POST and wsdl GET now. So what would I use to send static data? Do I need to implement my own servlet?

      Code:
      54          if ("POST".equals(httpServletRequest.getMethod())) {
      55              WebServiceConnection connection = new HttpServletConnection(httpServletRequest, httpServletResponse);
      56              handleConnection(connection, (WebServiceMessageReceiver) handler);
      57              return null;
      58          }
      59          else {
      60              httpServletResponse.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
      61              return null;
      62          }
      
      193         if ("GET".equals(request.getMethod()) && request.getRequestURI().endsWith(WSDL_SUFFIX_NAME)) {
      194             String fileName = WebUtils.extractFilenameFromUrlPath(request.getRequestURI());
      195             return (WsdlDefinition) wsdlDefinitions.get(fileName);
      196         }
      197         else {
      198             return null;
      199         }
      My real problem is with the auto generated WSDL I have a type library that I import into my application schema and the WSDL that's generated contains the relative path and doesn't automatically load the type library into the main schema. This would be fine, but when I try and use the generated WSDL (for example with soapUI) it trys to download the type library and it can't because of the above issue.

      Here a sample WSDL. The schemaLocation is a relative path and is not loaded in the auto generated WSDL.

      Code:
      - <wsdl:types>
      - <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sample.com/sample" xmlns:s1="http://www.sample.com/s1" elementFormDefault="unqualified" targetNamespace="http://www.sample/sample">
        <xsd:import namespace="http://www.sample.com/s1" schemaLocation="../sample/sample.xsd" /> 
        <xsd:element name="TestRequest" type="s1:name" /> 
        </xsd:schema>
        </wsdl:types>
      When I try to import using soapUI, I get the following error. The ".." is applied to the root rather than relative path to the schema that is importing it.

      Code:
      Tue Jul 03 10:53:56 EDT 2007:DEBUG:Returning baseURI [http://localhost:7001/sample-ws/sample.wsdl]
      Tue Jul 03 10:53:56 EDT 2007:DEBUG:Returning baseURI [http://localhost:7001/sample-ws/sample.wsdl]
      Tue Jul 03 10:53:56 EDT 2007:DEBUG:Getting wsdl component from [http://localhost:7001/sample-ws/sample.wsdl]
      Tue Jul 03 10:53:56 EDT 2007:DEBUG:Getting wsdl component from [http://locahost:7001/sample/sample.xsd]
      Tue Jul 03 10:53:56 EDT 2007:ERROR:Loading of definition failed for [http://localhost:7001/sample-ws/sample.wsdl]; org.apache.xmlbeans.XmlException: error: Unexpected element: TAG_END
      Tue Jul 03 10:53:56 EDT 2007:ERROR:Error importing wsdl: org.apache.xmlbeans.XmlException: error: Unexpected element: TAG_END

      Comment


      • #4
        Originally posted by lgothard View Post
        Do I need to implement my own servlet?
        You could change the url pattern of your MessageDispatcherServlet to not match the names of your static files. That way, your request would be handled by your servlet container's default servlet, which serves static files all right (at least that's how it works on Tomcat using DefaultServlet).

        Comment


        • #5
          Thank you. This works. The equivalent to DefaultServlet in Weblogic is FielServlet. Has anyone used

          org.springframework.web.servlet.ResourceServlet

          I'm wondering if this would be used instead. I can't seem to fiind any examples and what I tried didn't seem to work.

          The only problem I have now is with the schemaLocation. I currently have the following in my application schema.

          Code:
          <xsd:import namespace="http://www.sample.com/sample" schemaLocation="http://localhost:7001/my-app/xsd/common/types.xsd" />
          This has to be changed when deployed to different servers. Does anyone know a way to make this dynamic? I'm thinking I'll have to make this part of the build process somehow.

          Comment

          Working...
          X