10 Replies Latest reply on Jan 15, 2007 7:16 PM by Jason Greene

    Exception while deploying a webservice with attachment (star

    nafees sharif Newbie

      Hi All

      I am trying to create a webservice that can receive an attachment alongwith a few other parameters. I am starting from a WSDL file and i am specifying attachments using mime content element as shown in the code below:

      <definitions
       name = "Gasherbrum"
       targetNamespace = "http://org.jboss.test.webservice/samples2"
       xmlns:tns = "http://org.jboss.test.webservice/samples2"
       xmlns = "http://schemas.xmlsoap.org/wsdl/"
       xmlns:ns2 = "http://org.jboss.test.webservice/samples2/types"
       xmlns:mime = "http://schemas.xmlsoap.org/wsdl/mime/"
       xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
       xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/">
       <types>
       <schema
       targetNamespace = "http://org.jboss.test.webservice/samples2/types"
       xmlns:tns = "http://org.jboss.test.webservice/samples2/types"
       xmlns:soap11-enc = "http://schemas.xmlsoap.org/soap/encoding/"
       xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
       xmlns:wsdl = "http://schemas.xmlsoap.org/wsdl/"
       xmlns = "http://www.w3.org/2001/XMLSchema">
       <complexType name = "paraListType">
       <sequence>
       <element
       name = "username"
       type = "string"
       nillable = "true"/>
       <element
       name = "password"
       type = "string"
       nillable = "true"/>
       <element
       name = "operationName"
       type = "string"
       nillable = "true"/>
       <element
       name = "inputXML"
       type = "string"
       nillable = "true"/>
       </sequence>
       </complexType>
       <complexType name = "responseType">
       <sequence>
       <element
       name = "result"
       type = "string"
       nillable = "true"/>
       </sequence>
       </complexType>
       <element name = "paraList2" type = "tns:paraListType"/>
       <element name = "responseXML" type = "tns:responseType"/>
       </schema>
       </types>
       <message name = "attachRequest">
       <part name = "parameters" element = "ns2:paraList2"/>
       <part name = "attachmentContents" type = "xsd:string"/>
       </message>
       <message name = "attachResponse">
       <part name = "result" element = "ns2:responseXML"/>
       </message>
       <portType name = "TransmulatorInterface">
       <operation name = "invokeAttach">
       <input message = "tns:attachRequest"/>
       <output message = "tns:attachResponse"/>
       </operation>
       </portType>
       <binding name = "TransmulatorInterfaceBinding" type = "tns:TransmulatorInterface">
       <soap:binding transport = "http://schemas.xmlsoap.org/soap/http" style = "document"/>
       <operation name = "invokeAttach">
       <input>
       <mime:multipartRelated>
       <mime:part>
       <soap:body use = "literal"/>
       </mime:part>
       <mime:part>
       <mime:content part = "attachmentContents" type = "text/plain"/>
       </mime:part>
       </mime:multipartRelated>
       </input>
       <output>
       <mime:multipartRelated>
       <mime:part>
       <soap:body use = "literal"/>
       </mime:part>
       </mime:multipartRelated>
       </output>
       </operation>
       </binding>
       <service name = "Gasherbrum">
       <port name = "TransmulatorInterfacePort" binding = "tns:TransmulatorInterfaceBinding">
       <soap:address location = "REPLACE_WITH_ACTUAL_URL"/>
       </port>
       </service>
      </definitions>
      



      This WSDL generates SEI without any problems and get deploed easily on tomcat using JWSDP1.6, but when i tried the same WSDL file and tried to generate SEI through wscmopile and tried to deploy on JBoss, i get the following deployment exception:

      22:11:09,354 WARN [JavaWsdlMapping] Cannot find jaxrpc-mapping for type: {http://www.w3.org/2001/XMLSchema}string
      22:11:09,354 ERROR [MainDeployer] Could not create deployment: file:/D:/jboss-4.0.4.GA/server/default/deploy/alhamd.war
      org.jboss.ws.WSException: Cannot obtain java/xml type mapping for: {http://www.w3.org/2001/XMLSchema}string
       at org.jboss.ws.deployment.JSR109MetaDataBuilder.buildParameterMetaDataDoc(JSR109MetaDataBuilder.java:513)
       at org.jboss.ws.deployment.JSR109MetaDataBuilder.setupOperationsFromWSDL(JSR109MetaDataBuilder.java:200)
       at org.jboss.ws.deployment.JSR109ServerMetaDataBuilder.buildMetaData(JSR109ServerMetaDataBuilder.java:223)
       at org.jboss.ws.deployment.ServiceEndpointDeployer.create(ServiceEndpointDeployer.java:78)
       at org.jboss.ws.integration.jboss.DeployerInterceptor.create(DeployerInterceptor.java:80)
       at org.jboss.ws.integration.jboss.DeployerInterceptorJSE.create(DeployerInterceptorJSE.java:74)
       at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.create(SubDeployerInterceptorSupport.jav
      a:180)
       at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:91)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy31.create(Unknown Source)
       at org.jboss.deployment.MainDeployer.create(MainDeployer.java:953)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:807)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
       at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy8.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:26
      3)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
      
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
      


      I cant seem to figure out what the problem is!

      Is it that attachments are not supported in JBoss (i am using 4.0.4 with jbossws as add-on)?? or are they not supported when starting from WSDL file? Or am i ignoring something here?



      Any clues in this regard would be highly appreciated.


      Regards,
      mnsharif

        • 1. anyone from JBoss' working group??
          nafees sharif Newbie

           

          "mnsharif" wrote:

          Is it that attachments are not supported in JBoss (i am using 4.0.4 with jbossws as add-on)?? or are they not supported when starting from WSDL file? Or am i ignoring something here?



          Can anyone from JBoss itself answer these question if a certain thing is possible or not under the current jboss release!

          Thanks a lot!

          mnsharif

          • 2. Re: Exception while deploying a webservice with attachment (
            Romeu Figueira Newbie

            To deal with attachments within JBoss WS, you will need the the following files:

            jax-mapping.xml (maps values to the wsdl)
            webservices.xml
            web.xml
            your_wsdl_file.wsdl
            your_class_files.class

            The first three can be generated by wstools, altough from my personal experience, some manual tweaking is necessary.

            • 3. Re: anyone from JBoss' working group??
              Ales Justin Master

               

              "mnsharif" wrote:
              Can anyone from JBoss itself answer these question if a certain thing is possible or not under the current jboss release!


              This kind of attitude will get you nowhere.
              It's all open source - look it up yourself - if it is possible to do certain things.

              • 4. Re: Exception while deploying a webservice with attachment (
                nafees sharif Newbie

                People post their problems here when they run short of ideas on their own and they expect others to help. Anyway, thanks for all the help that was provided (my issue is still unresolved though).



                RomeuFigueira!

                As you mentioned about the files required for dealing with attachments in JBoss WS, i have created them all (but havent tweaked any of them manually).


                It looks like that http://jira.jboss.com/jira/browse/JBWS-269 suggest that wstools (the tool from JBoss) does not currently support attachments. In either case, i am using wscompile (from JWSDPv1.6) to generate SEI and mapping file from a hand-written WSDL file. Then i write a web.xml and webservices.xml file by hand as well to complete the deployment package.

                So, technically i have everything in place and i used same WSDL file to generate artifacts and published web service successfully on tomcat using JWSDP.

                To frustrate me enough, the error that i get is

                org.jboss.ws.WSException:
                Cannot obtain java/xml type mapping for: {http://www.w3.org/2001/XMLSchema}string

                where we all know that the given schema DOES contain a data type with the name string

                So, what's wrong with my implementation? any clues? anyone?


                mnsharif

                • 5. Re: Exception while deploying a webservice with attachment (
                  Romeu Figueira Newbie

                  Indeed you are right, wstools does not go along with more complex types necessary for attachment. One has to do them by hand, or using a place holder.

                  As for the mapping error, in your jaxrcp-mapping.xml do you place strings as:

                  <param-type>java.lang.String</param-type>
                  ?

                  And in your wsdl file, do you have them as:
                  .... type='xsd:string'/>
                  ?

                  Note: the prefix xsd is linked with the following namespace (xmlns:xsd='http://www.w3.org/2001/XMLSchema'>)

                  • 6. Re: Exception while deploying a webservice with attachment (
                    nafees sharif Newbie

                    Yeah, the generated jaxrpc-mapping.xml does have

                    <param-type>java.lang.String</param-type>
                    and Yes, i do have
                    .... type='xsd:string'/>
                    like thing in my part definitions in WSDL. But that is there for a reason, which i will try to explain.


                    As a matter of fact, wscompile does not allow to have primitive types (like xsd:string etc) to be specified like following:
                    <message name = "methodName">
                     <part name = "paraName" element = "xsd:string"/>
                    </message>

                    If used, wscompile gives error and skips mapping for this method. Please note that this behavior is peculiar to document based web wervices _only_ (this is allowed in rpc style). So, in document based services, i have to wrap these primitive types in wrapper types like this
                    <message name = "methodName">
                     <part name = "paraName" element = "ns2:wrapperString"/>
                    </message>

                    and then, combination of following fragment in types section of the WSDL gives me the equavilent desired effect.
                    <complexType name = "wrapperStringType">
                     <sequence>
                     <element
                     name = "parameterOne"
                     type = "string"
                     nillable = "true"/>
                     </sequence>
                    </complexType>
                    <element name = "wrapperString" type = "tns:wrapperStringType"/>
                    




                    Now everything is fine with attachment-less webservices. But for the web-service where i need attachment support, the message _has_ to be defined as
                    <message name = "methodWithAttachment">
                     <part name = "paraName" element = "ns2:wrapperString"/>
                     <part name = "attachmentContents" type = "xsd:string"/>
                    </message>

                    Interestingly enough, the wscompile tool does _not_ show any error/warning while generating mapping. The attachmentContents above is my parameter defined in mime:content (which happens to be of type text/plain), so that could be the possible reason of wscompile staying silent on this part being specified as xsd:string.

                    But at deployment time i get the following warning and then exception (as i mentioned in my first post):
                    22:11:09,354 WARN [JavaWsdlMapping] Cannot find jaxrpc-mapping for type: {http://www.w3.org/2001/XMLSchema}string
                    22:11:09,354 ERROR [MainDeployer] Could not create deployment: file:/D:/jboss-4.0.4.GA/server/default/deploy/alhamd.war
                    org.jboss.ws.WSException: Cannot obtain java/xml type mapping for: {http://www.w3.org/2001/XMLSchema}string
                    at org.jboss.ws.deployment.JSR109MetaDataBuilder.buildParameterMetaDataDoc(JSR109MetaDataBuilder.java:513)



                    Phew! No wonder, writing this all down is more difficult than explaining on face.


                    mnsharif

                    • 7. Re: Exception while deploying a webservice with attachment (
                      nafees sharif Newbie

                      Sorry, the correct third code snippet is as follows:

                      <message name = "methodName">
                       <part name = "paraName" type = "xsd:string"/>
                      </message>


                      notice that it is type = "xsd:string" and not element = "xsd:string", as i wrote in my last post by mistake.


                      mnsharif

                      • 9. Re: Exception while deploying a webservice with attachment (
                        Jason Greene Master

                         

                        "mnsharif" wrote:
                        Sorry, the correct third code snippet is as follows:

                        <message name = "methodName">
                         <part name = "paraName" type = "xsd:string"/>
                        </message>


                        notice that it is type = "xsd:string" and not element = "xsd:string", as i wrote in my last post by mistake.


                        mnsharif


                        With document literal, all parts must be referenced using element= and not type=. This of course requires that you create an element definition with a type of xsd:string.

                        • 10. Re: Exception while deploying a webservice with attachment (
                          Jason Greene Master

                           

                          "jason.greene@jboss.com" wrote:
                          "mnsharif" wrote:
                          Sorry, the correct third code snippet is as follows:

                          <message name = "methodName">
                           <part name = "paraName" type = "xsd:string"/>
                          </message>


                          notice that it is type = "xsd:string" and not element = "xsd:string", as i wrote in my last post by mistake.


                          mnsharif


                          With document literal, all parts must be referenced using element= and not type=. This of course requires that you create an element definition with a type of xsd:string.


                          Nevermind, type should be allowed according to AP 1.0. I will look into the error further.