Announcement Announcement Module
Collapse
No announcement yet.
XPathParam is NaN Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • XPathParam is NaN

    I'm using Netbeans to test my WebService, and each time it sends the request, my endpoint receives NaNs for its XPathParams. I'm not sure if I'm not doing the XPathParam properly or what, but it seems pretty straight forward.

    Here's the SOAP request from Netbeans:
    Code:
    <?xml version="1.0" ?>
       <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
          <S:Body>
             <ns1:getCatalogPageRequest xmlns:ns1="http://www.12gaugemedia.com/shotgun-ws/services/catalog">
                <ns1:siteId>0</ns1:siteId>
                <ns1:folderId>0</ns1:folderId>
                <ns1:page>0</ns1:page>
                <ns1:resultsPerPage>0</ns1:resultsPerPage>
             </ns1:getCatalogPageRequest>
          </S:Body>
       </S:Envelope>
    Here's my EndPoint:
    Code:
        @PayloadRoot(localPart = GET_CATALOG_PAGE_REQUEST, namespace = NAMESPACE_URI)
        public Source getCatalogPageRequest(@XPathParam("//siteId") double siteId, 
                                            @XPathParam("//folderId") double folderId, 
                                            @XPathParam("//page") double page, 
                                            @XPathParam("//resultsPerPage") double resultsPerPage){
          ...
    I've tried "//ns1:siteId" and "//tns:siteId" (since my xsd has the namespace "xmlns:tns" defined), however, they all return NaN.

    Any ideas why I'd be getting NaN for all values of this request? Thanks!

  • #2
    Basically, you need to bind the prefix to the correct namespace in the XPathParamAnnotationMethodEndpointAdapter. The fact that you defined them in the schema does not help this adapter. The airline sample shows how.

    Comment


    • #3
      Thanks for your response, Arjen.

      So just to clarify, are you saying that my @PayloadRoot annotation namespace needs to point to a url that has a "ns1" namespace defined that matches the SOAP request?

      Therefore:

      @PayloadRoot(localPart = GET_CATALOG_PAGE_REQUEST, namespace = NAMESPACE_URI)

      "NAMESPACE_URI" needs to resolve to the URL of a schema that has a matching namespace defined:

      xmlns:ns1="http://www.12gaugemedia.com/shotgun-ws/services/catalog"

      Is that correct, or am I not following...

      Comment


      • #4
        Oh, I see what you're saying. So I tried adding it to the bean's definition, however, it still isn't resolving:

        Code:
        <bean class="org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter">
            <property name="namespaces">
                <props>
                    <prop key="tns">http://www.12gaugemedia.com/shotgun-ws/services/catalog</prop>
                    <prop key="ns1">http://www.12gaugemedia.com/shotgun-ws/services/catalog</prop>
                </props>
            </property>
        </bean>

        Comment


        • #5
          Ok, so I figured it out. I added the "ns1" namespace mapping to the bean defintition, and then used "//ns1:..." to reference the values in my classes (instead of just the node name).

          Is there any particular reason "ns1" is used? Is there a way for responses to use a particular namespace? I hadn't defined "ns1" anywhere previously, however, it's being used in both the request and response. The only namespaces I had previously defined were "ns" and "tns". My concern is that if I expose my web services externally, will I have to be concerned about web service clients using different namespaces, which won't resolve in my endpoint since it's hard-coded to "ns1:..."?

          Comment


          • #6
            ns1 is a namespace prefix, and not a namespaces URI. The prefix name is not significant, only the namespace URI is. You could change ns1 to jigamadoob and (supposing you change the prefix in the expression) it would still work with clients using ns1.

            Comment

            Working...
            X