4 Replies Latest reply on Dec 16, 2005 10:09 AM by Jason Greene

    Web Service Authentication

    roberto roberto Novice

      I build a new Java Web Service and works fine.
      So now i decide to active authentication for that web service.
      As a simply way i set in the security-constraint my web service URL and set the login-config / auth-method to BASIC.
      My client set properties username and pwd and all works fine also.

      But i have a little problem, my real web archive (war) use FORM as auth-method and it's not possible to have two different auth method in the same WAR!!!
      If i use FORM auth method, my client cannot connect and some exception occurs.
      The exception it's strange because don't say "unauthenticated.. " but:

      Exception in thread "main" AxisFault
      faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
      faultSubcode:
      faultString: Missing whitespace before SYSTEM literal URI.
      faultActor:
      faultNode:
      faultDetail:
      {http://xml.apache.org/axis/}stackTrace: org.xml.sax.SAXParseException: Missing whitespace before SYSTEM literal
      URI.
      at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
      at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3370)
      at org.apache.crimson.parser.Parser2.whitespace(Parser2.java:736)
      at org.apache.crimson.parser.Parser2.maybeExternalID(Parser2.java:2922)
      at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1309)
      at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:656)
      at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
      at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
      at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
      at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:258)
      at org.apache.axis.MessagePart.getAsSOAPEnvelope(MessagePart.java:657)
      at org.apache.axis.Message.getSOAPEnvelope(Message.java:430)
      at org.apache.axis.client.Call.invokeEngine(Call.java:3052)
      at org.apache.axis.client.Call.invoke(Call.java:3014)
      at org.apache.axis.client.Call.invoke(Call.java:2608)
      at org.apache.axis.client.Call.invoke(Call.java:2513)
      at org.apache.axis.client.Call.invokeInternal(Call.java:1973)
      at org.apache.axis.client.Call.invoke(Call.java:1914)
      at com.dat.abs.web.ws.Client.useOfDynamicInvocationInterfaceClient(Client.java:101)
      at com.dat.abs.web.ws.Client.main(Client.java:34)


      org.apache.axis.AxisFault: Missing whitespace before SYSTEM literal URI.
      at org.apache.axis.AxisFault.makeFault(AxisFault.java:146)
      at org.apache.axis.MessagePart.getAsSOAPEnvelope(MessagePart.java:664)
      at org.apache.axis.Message.getSOAPEnvelope(Message.java:430)
      at org.apache.axis.client.Call.invokeEngine(Call.java:3052)
      at org.apache.axis.client.Call.invoke(Call.java:3014)
      at org.apache.axis.client.Call.invoke(Call.java:2608)
      at org.apache.axis.client.Call.invoke(Call.java:2513)
      at org.apache.axis.client.Call.invokeInternal(Call.java:1973)
      at org.apache.axis.client.Call.invoke(Call.java:1914)
      at com.dat.abs.web.ws.Client.useOfDynamicInvocationInterfaceClient(Client.java:101)
      at com.dat.abs.web.ws.Client.main(Client.java:34)
      Caused by: org.xml.sax.SAXParseException: Missing whitespace before SYSTEM literal URI.
      at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
      at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3370)
      at org.apache.crimson.parser.Parser2.whitespace(Parser2.java:736)
      at org.apache.crimson.parser.Parser2.maybeExternalID(Parser2.java:2922)
      at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1309)
      at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:656)
      at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
      at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
      at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
      at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:258)
      at org.apache.axis.MessagePart.getAsSOAPEnvelope(MessagePart.java:657)
      ... 9 more

      So.. how can i use FORM authentication for a web service?

      Or i must deploy web services in another WAR module?

      or configure some other parameters?

      This is my webservice.xml:

      <webservices xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd" version="1.1">
      <webservice-description>
      <webservice-description-name>HelloService</webservice-description-name>
      <wsdl-file>WEB-INF/wsdl/HelloService.wsdl</wsdl-file>
      <jaxrpc-mapping-file>WEB-INF/mapping.xml</jaxrpc-mapping-file>
      <port-component>
      <port-component-name>ABSActionJSEEndpointsInterface</port-component-name>
      <wsdl-port>ABSActionJSEEndpointsInterfacePort</wsdl-port>
      <service-endpoint-interface>com.dat.abs.web.ws.ABSActionJSEEndpointsInterface</service-endpoint-interface>
      <service-impl-bean>
      <servlet-link>ABSActionJSEEndpoints</servlet-link>
      </service-impl-bean>
      </port-component>
      </webservice-description>


      _____________________

      mapping.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <java-wsdl-mapping xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd">
      <package-mapping>
      <package-type>com.dat.abs.web.ws</package-type>
      http://ws.web.abs.dat.com/types
      </package-mapping>
      <package-mapping>
      <package-type>com.dat.abs.web.ws</package-type>
      http://ws.web.abs.dat.com/
      </package-mapping>
      <service-interface-mapping>
      <service-interface>com.dat.abs.web.ws.HelloService</service-interface>
      <wsdl-service-name xmlns:serviceNS="http://ws.web.abs.dat.com/">serviceNS:HelloService</wsdl-service-name>
      <port-mapping>
      <port-name>ABSActionJSEEndpointsInterfacePort</port-name>
      <java-port-name>ABSActionJSEEndpointsInterfacePort</java-port-name>
      </port-mapping>
      </service-interface-mapping>
      <service-endpoint-interface-mapping>
      <service-endpoint-interface>com.dat.abs.web.ws.ABSActionJSEEndpointsInterface</service-endpoint-interface>
      <wsdl-port-type xmlns:portTypeNS="http://ws.web.abs.dat.com/">portTypeNS:ABSActionJSEEndpointsInterface</wsdl-port-type>
      <wsdl-binding xmlns:bindingNS="http://ws.web.abs.dat.com/">bindingNS:ABSActionJSEEndpointsInterfaceBinding</wsdl-binding>
      <service-endpoint-method-mapping>
      <java-method-name>existsBusinessPartner</java-method-name>
      <wsdl-operation>existsBusinessPartner</wsdl-operation>
      <method-param-parts-mapping>
      <param-position>0</param-position>
      <param-type>java.lang.String</param-type>
      <wsdl-message-mapping>
      <wsdl-message xmlns:wsdlMsgNS="http://ws.web.abs.dat.com/">wsdlMsgNS:ABSActionJSEEndpointsInterface_existsBusinessPartner</wsdl-message>
      <wsdl-message-part-name>String_1</wsdl-message-part-name>
      <parameter-mode>IN</parameter-mode>
      </wsdl-message-mapping>
      </method-param-parts-mapping>
      <wsdl-return-value-mapping>
      <method-return-value>boolean</method-return-value>
      <wsdl-message xmlns:wsdlMsgNS="http://ws.web.abs.dat.com/">wsdlMsgNS:ABSActionJSEEndpointsInterface_existsBusinessPartnerResponse</wsdl-message>
      <wsdl-message-part-name>result</wsdl-message-part-name>
      </wsdl-return-value-mapping>
      </service-endpoint-method-mapping>
      <service-endpoint-method-mapping>
      <java-method-name>getBusinessPartner</java-method-name>
      <wsdl-operation>getBusinessPartner</wsdl-operation>
      <method-param-parts-mapping>
      <param-position>0</param-position>
      <param-type>java.lang.String</param-type>
      <wsdl-message-mapping>
      <wsdl-message xmlns:wsdlMsgNS="http://ws.web.abs.dat.com/">wsdlMsgNS:ABSActionJSEEndpointsInterface_getBusinessPartner</wsdl-message>
      <wsdl-message-part-name>String_1</wsdl-message-part-name>
      <parameter-mode>IN</parameter-mode>
      </wsdl-message-mapping>
      </method-param-parts-mapping>
      <wsdl-return-value-mapping>
      <method-return-value>java.lang.String</method-return-value>
      <wsdl-message xmlns:wsdlMsgNS="http://ws.web.abs.dat.com/">wsdlMsgNS:ABSActionJSEEndpointsInterface_getBusinessPartnerResponse</wsdl-message>
      <wsdl-message-part-name>result</wsdl-message-part-name>
      </wsdl-return-value-mapping>
      </service-endpoint-method-mapping>
      </service-endpoint-interface-mapping>
      </java-wsdl-mapping>

      __________________________________________________

      my wsdl.

      <?xml version="1.0" encoding="UTF-8"?>
      <definitions name="HelloService" targetNamespace="http://ws.web.abs.dat.com/" xmlns:tns="http://ws.web.abs.dat.com/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">

















      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>

      <soap:operation soapAction=""/>

      <soap:body use="literal" namespace="http://ws.web.abs.dat.com/"/>

      <soap:body use="literal" namespace="http://ws.web.abs.dat.com/"/>

      <soap:operation soapAction=""/>

      <soap:body use="literal" namespace="http://ws.web.abs.dat.com/"/>

      <soap:body use="literal" namespace="http://ws.web.abs.dat.com/"/>


      <soap:address location="REPLACE_WITH_ACTUAL_URL"/>

      Thank You!

        • 1. Re: Web Service Authentication
          Jason Greene Master

          FORM authentication doesn't make sense for a webservice client. The only way around this problem is to package your webservices in another war file. You can then package them together in an ear file.

          -Jason

          • 2. Re: Web Service Authentication
            roberto roberto Novice

            Thank You
            i suppose it..
            i will be glad if i can be able to use only one war module....

            Roberto

            • 3. Re: Web Service Authentication
              roberto roberto Novice

              i forgot ...
              i prefer to use only one war because i have hundreds of ejb-ref to point to ejb session
              (and for my application purpose i prefer to publish a java web service and not an ejb web service)

              Thank You again Jason

              • 4. Re: Web Service Authentication
                Jason Greene Master

                You can accomplish something like this by using the replace ant task in your build system. So basically you make two files. One that contains the ejb-ref tags that are in your web.xml, and the other that contains the ones in jboss-web.xml.

                You then add a comment to both your web.xml and jboss-web.xml that has something like

                "<!-- insert ejb-refs here -->"
                


                and then you would have the following in some ant task

                <loadfile property="ejb-refs-content" srcFile="ejb-refs.xml"/>
                <loadfile property="jboss-ejb-refs-content" srcfile="jboss-ejb-refs.xml"/>
                <replace file="web.xml">
                 <replacefilter token="<!-- insert ejb-refs here -->" value="${ejb-refs-content}"/>
                </replace>
                <replace file="jboss-web.xml">
                 <replacefilter token="<!-- insert ejb-refs here -->" value="${jboss-ejb-refs-content}"/>
                </replace>
                


                Hope that helps!

                -Jason