[jboss-user] [JBossWS] - Re: UsernameToken authentication using JBossWS

Leandro Sales leandroal at gmail.com
Mon Dec 10 12:24:43 EST 2007


Hi Alessio and others,

   any new clue about this? Thank you,

Leandro.

2007/12/7, Leandro Sales <leandroal at gmail.com>:
> Hello, please consider de following WSDL:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
> xmlns:tns="http://www.xxx.com/" xmlns:s1="http://www.xxx.com/security"
> xmlns:s="http://www.w3.org/2001/XMLSchema"
> xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
> xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
> targetNamespace="http://www.xxx.com/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
>   <wsdl:documentation
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">This web service
> provides real-time data data.</wsdl:documentation>
>   <wsdl:types>
>     <s:schema elementFormDefault="qualified"
> targetNamespace="http://www.xxx.com/">
>       <s:element name="GetStations">
>         <s:complexType/>
>       </s:element>
>       <s:element name="GetStationsResponse">
>         <s:complexType>
>           <s:sequence>
>             <s:element minOccurs="0" maxOccurs="1"
> name="GetStationsResult" type="tns:ArrayOfStation"/>
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>       <s:complexType name="ArrayOfStation">
>         <s:sequence>
>           <s:element minOccurs="0" maxOccurs="unbounded"
> name="Station" nillable="true" type="tns:Station"/>
>         </s:sequence>
>       </s:complexType>
>       <s:complexType name="Station">
>         <s:sequence>
>           <s:element minOccurs="0" maxOccurs="1" name="StationName"
> type="s:string"/>
>           <s:element minOccurs="1" maxOccurs="1" name="StationNumber"
> type="s:int"/>
>           <s:element minOccurs="1" maxOccurs="1" name="Altitude"
> type="s:double"/>
>           <s:element minOccurs="1" maxOccurs="1" name="Latitude"
> type="s:double"/>
>           <s:element minOccurs="1" maxOccurs="1" name="Longitude"
> type="s:double"/>
>           <s:element minOccurs="1" maxOccurs="1" name="SensorHeight"
> type="s:double"/>
>         </s:sequence>
>       </s:complexType>
>       <s:element name="GetObservationVariablesByStation">
>         <s:complexType>
>           <s:sequence>
>             <s:element minOccurs="0" maxOccurs="1" name="stationName"
> type="s:string"/>
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>       <s:element name="GetObservationVariablesByStationResponse">
>         <s:complexType>
>           <s:sequence>
>             <s:element minOccurs="0" maxOccurs="1"
> name="GetObservationVariablesByStationResult"
> type="tns:ArrayOfString"/>
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>       <s:complexType name="ArrayOfString">
>         <s:sequence>
>           <s:element minOccurs="0" maxOccurs="unbounded" name="string"
> nillable="true" type="s:string"/>
>         </s:sequence>
>       </s:complexType>
>       <s:element name="GetLatestObservationByStationAndVariable">
>         <s:complexType>
>           <s:sequence>
>             <s:element minOccurs="0" maxOccurs="1" name="stationName"
> type="s:string"/>
>             <s:element minOccurs="0" maxOccurs="1" name="obsVariable"
> type="s:string"/>
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>       <s:element name="GetLatestObservationByStationAndVariableResponse">
>         <s:complexType>
>           <s:sequence>
>             <s:element minOccurs="0" maxOccurs="1"
> name="GetLatestObservationByStationAndVariableResult"
> type="tns:Observation"/>
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>       <s:complexType name="Observation">
>         <s:sequence>
>           <s:element minOccurs="0" maxOccurs="1" name="ObsVariable"
> type="s:string"/>
>           <s:element minOccurs="0" maxOccurs="1"
> name="ObsVariableUnit" type="s:string"/>
>           <s:element minOccurs="1" maxOccurs="1" name="ObsValue"
> type="s:double"/>
>           <s:element minOccurs="1" maxOccurs="1" name="ObsTime"
> type="s:dateTime"/>
>           <s:element minOccurs="1" maxOccurs="1" name="ObsStatus" type="s:int"/>
>         </s:sequence>
>       </s:complexType>
>       <s:element name="GetLatestObservationsByStation">
>         <s:complexType>
>           <s:sequence>
>             <s:element minOccurs="0" maxOccurs="1" name="stationName"
> type="s:string"/>
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>       <s:element name="GetLatestObservationsByStationResponse">
>         <s:complexType>
>           <s:sequence>
>             <s:element minOccurs="0" maxOccurs="1"
> name="GetLatestObservationsByStationResult"
> type="tns:ArrayOfObservation"/>
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>       <s:complexType name="ArrayOfObservation">
>         <s:sequence>
>           <s:element minOccurs="0" maxOccurs="unbounded"
> name="Observation" nillable="true" type="tns:Observation"/>
>         </s:sequence>
>       </s:complexType>
>       <s:element name="GetObservationsByStationAndVariable">
>         <s:complexType>
>           <s:sequence>
>             <s:element minOccurs="0" maxOccurs="1" name="stationName"
> type="s:string"/>
>             <s:element minOccurs="0" maxOccurs="1" name="obsVariable"
> type="s:string"/>
>             <s:element minOccurs="1" maxOccurs="1" name="start"
> type="s:dateTime"/>
>             <s:element minOccurs="1" maxOccurs="1" name="stop"
> type="s:dateTime"/>
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>       <s:element name="GetObservationsByStationAndVariableResponse">
>         <s:complexType>
>           <s:sequence>
>             <s:element minOccurs="0" maxOccurs="1"
> name="GetObservationsByStationAndVariableResult"
> type="tns:ArrayOfObservation"/>
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>       <s:element name="GetObservationsByStation">
>         <s:complexType>
>           <s:sequence>
>             <s:element minOccurs="0" maxOccurs="1" name="stationName"
> type="s:string"/>
>             <s:element minOccurs="1" maxOccurs="1" name="start"
> type="s:dateTime"/>
>             <s:element minOccurs="1" maxOccurs="1" name="stop"
> type="s:dateTime"/>
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>       <s:element name="GetObservationsByStationResponse">
>         <s:complexType>
>           <s:sequence>
>             <s:element minOccurs="0" maxOccurs="1"
> name="GetObservationsByStationResult" type="tns:ArrayOfObservation"/>
>           </s:sequence>
>         </s:complexType>
>       </s:element>
>     </s:schema>
>     <s:schema elementFormDefault="qualified"
> targetNamespace="http://www.xxx.com/security">
>       <s:element name="UsernameToken" type="s1:UsernameToken"/>
>       <s:complexType name="UsernameToken">
>         <s:sequence>
>           <s:element minOccurs="0" maxOccurs="1" name="username"
> type="s:string"/>
>           <s:element minOccurs="0" maxOccurs="1" name="password"
> type="s:string"/>
>         </s:sequence>
>         <s:anyAttribute/>
>       </s:complexType>
>     </s:schema>
>   </wsdl:types>
>   <wsdl:message name="GetStationsSoapIn">
>     <wsdl:part name="parameters" element="tns:GetStations"/>
>   </wsdl:message>
>   <wsdl:message name="GetStationsSoapOut">
>     <wsdl:part name="parameters" element="tns:GetStationsResponse"/>
>   </wsdl:message>
>   <wsdl:message name="GetStationsUsernameToken">
>     <wsdl:part name="UsernameToken" element="s1:UsernameToken"/>
>   </wsdl:message>
>   <wsdl:message name="GetObservationVariablesByStationSoapIn">
>     <wsdl:part name="parameters"
> element="tns:GetObservationVariablesByStation"/>
>   </wsdl:message>
>   <wsdl:message name="GetObservationVariablesByStationSoapOut">
>     <wsdl:part name="parameters"
> element="tns:GetObservationVariablesByStationResponse"/>
>   </wsdl:message>
>   <wsdl:message name="GetObservationVariablesByStationUsernameToken">
>     <wsdl:part name="UsernameToken" element="s1:UsernameToken"/>
>   </wsdl:message>
>   <wsdl:message name="GetLatestObservationByStationAndVariableSoapIn">
>     <wsdl:part name="parameters"
> element="tns:GetLatestObservationByStationAndVariable"/>
>   </wsdl:message>
>   <wsdl:message name="GetLatestObservationByStationAndVariableSoapOut">
>     <wsdl:part name="parameters"
> element="tns:GetLatestObservationByStationAndVariableResponse"/>
>   </wsdl:message>
>   <wsdl:message name="GetLatestObservationByStationAndVariableUsernameToken">
>     <wsdl:part name="UsernameToken" element="s1:UsernameToken"/>
>   </wsdl:message>
>   <wsdl:message name="GetLatestObservationsByStationSoapIn">
>     <wsdl:part name="parameters" element="tns:GetLatestObservationsByStation"/>
>   </wsdl:message>
>   <wsdl:message name="GetLatestObservationsByStationSoapOut">
>     <wsdl:part name="parameters"
> element="tns:GetLatestObservationsByStationResponse"/>
>   </wsdl:message>
>   <wsdl:message name="GetLatestObservationsByStationUsernameToken">
>     <wsdl:part name="UsernameToken" element="s1:UsernameToken"/>
>   </wsdl:message>
>   <wsdl:message name="GetObservationsByStationAndVariableSoapIn">
>     <wsdl:part name="parameters"
> element="tns:GetObservationsByStationAndVariable"/>
>   </wsdl:message>
>   <wsdl:message name="GetObservationsByStationAndVariableSoapOut">
>     <wsdl:part name="parameters"
> element="tns:GetObservationsByStationAndVariableResponse"/>
>   </wsdl:message>
>   <wsdl:message name="GetObservationsByStationAndVariableUsernameToken">
>     <wsdl:part name="UsernameToken" element="s1:UsernameToken"/>
>   </wsdl:message>
>   <wsdl:message name="GetObservationsByStationSoapIn">
>     <wsdl:part name="parameters" element="tns:GetObservationsByStation"/>
>   </wsdl:message>
>   <wsdl:message name="GetObservationsByStationSoapOut">
>     <wsdl:part name="parameters"
> element="tns:GetObservationsByStationResponse"/>
>   </wsdl:message>
>   <wsdl:message name="GetObservationsByStationUsernameToken">
>     <wsdl:part name="UsernameToken" element="s1:UsernameToken"/>
>   </wsdl:message>
>   <wsdl:portType name="xxx_x0020_Web_x0020_ServiceSoap">
>     <wsdl:operation name="GetStations">
>       <wsdl:documentation
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">...</wsdl:documentation>
>       <wsdl:input message="tns:GetStationsSoapIn"/>
>       <wsdl:output message="tns:GetStationsSoapOut"/>
>     </wsdl:operation>
>     <wsdl:operation name="GetObservationVariablesByStation">
>       <wsdl:documentation
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">...</wsdl:documentation>
>       <wsdl:input message="tns:GetObservationVariablesByStationSoapIn"/>
>       <wsdl:output message="tns:GetObservationVariablesByStationSoapOut"/>
>     </wsdl:operation>
>     <wsdl:operation name="GetLatestObservationByStationAndVariable">
>       <wsdl:documentation
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">...</wsdl:documentation>
>       <wsdl:input message="tns:GetLatestObservationByStationAndVariableSoapIn"/>
>       <wsdl:output
> message="tns:GetLatestObservationByStationAndVariableSoapOut"/>
>     </wsdl:operation>
>     <wsdl:operation name="GetLatestObservationsByStation">
>       <wsdl:documentation
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">...</wsdl:documentation>
>       <wsdl:input message="tns:GetLatestObservationsByStationSoapIn"/>
>       <wsdl:output message="tns:GetLatestObservationsByStationSoapOut"/>
>     </wsdl:operation>
>     <wsdl:operation name="GetObservationsByStationAndVariable">
>       <wsdl:documentation
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">...</wsdl:documentation>
>       <wsdl:input message="tns:GetObservationsByStationAndVariableSoapIn"/>
>       <wsdl:output message="tns:GetObservationsByStationAndVariableSoapOut"/>
>     </wsdl:operation>
>     <wsdl:operation name="GetObservationsByStation">
>       <wsdl:documentation
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">....</wsdl:documentation>
>       <wsdl:input message="tns:GetObservationsByStationSoapIn"/>
>       <wsdl:output message="tns:GetObservationsByStationSoapOut"/>
>     </wsdl:operation>
>   </wsdl:portType>
>   <wsdl:binding name="xxx_x0020_Web_x0020_ServiceSoap"
> type="tns:xxx_x0020_Web_x0020_ServiceSoap">
>     <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
>     <wsdl:operation name="GetStations">
>       <soap:operation soapAction="http://www.xxx.com/GetStations"
> style="document"/>
>       <wsdl:input>
>         <soap:body use="literal"/>
>         <soap:header message="tns:GetStationsUsernameToken"
> part="UsernameToken" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>     <wsdl:operation name="GetObservationVariablesByStation">
>       <soap:operation
> soapAction="http://www.xxx.com/GetObservationVariablesByStation"
> style="document"/>
>       <wsdl:input>
>         <soap:body use="literal"/>
>         <soap:header
> message="tns:GetObservationVariablesByStationUsernameToken"
> part="UsernameToken" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>     <wsdl:operation name="GetLatestObservationByStationAndVariable">
>       <soap:operation
> soapAction="http://www.xxx.com/GetLatestObservationByStationAndVariable"
> style="document"/>
>       <wsdl:input>
>         <soap:body use="literal"/>
>         <soap:header
> message="tns:GetLatestObservationByStationAndVariableUsernameToken"
> part="UsernameToken" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>     <wsdl:operation name="GetLatestObservationsByStation">
>       <soap:operation
> soapAction="http://www.xxx.com/GetLatestObservationsByStation"
> style="document"/>
>       <wsdl:input>
>         <soap:body use="literal"/>
>         <soap:header
> message="tns:GetLatestObservationsByStationUsernameToken"
> part="UsernameToken" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>     <wsdl:operation name="GetObservationsByStationAndVariable">
>       <soap:operation
> soapAction="http://www.xxx.com/GetObservationsByStationAndVariable"
> style="document"/>
>       <wsdl:input>
>         <soap:body use="literal"/>
>         <soap:header
> message="tns:GetObservationsByStationAndVariableUsernameToken"
> part="UsernameToken" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>     <wsdl:operation name="GetObservationsByStation">
>       <soap:operation
> soapAction="http://www.xxx.com/GetObservationsByStation"
> style="document"/>
>       <wsdl:input>
>         <soap:body use="literal"/>
>         <soap:header
> message="tns:GetObservationsByStationUsernameToken"
> part="UsernameToken" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>   </wsdl:binding>
>   <wsdl:binding name="xxx_x0020_Web_x0020_ServiceSoap12"
> type="tns:xxx_x0020_Web_x0020_ServiceSoap">
>     <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
>     <wsdl:operation name="GetStations">
>       <soap12:operation soapAction="http://www.xxx.com/GetStations"
> style="document"/>
>       <wsdl:input>
>         <soap12:body use="literal"/>
>         <soap12:header message="tns:GetStationsUsernameToken"
> part="UsernameToken" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap12:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>     <wsdl:operation name="GetObservationVariablesByStation">
>       <soap12:operation
> soapAction="http://www.xxx.com/GetObservationVariablesByStation"
> style="document"/>
>       <wsdl:input>
>         <soap12:body use="literal"/>
>         <soap12:header
> message="tns:GetObservationVariablesByStationUsernameToken"
> part="UsernameToken" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap12:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>     <wsdl:operation name="GetLatestObservationByStationAndVariable">
>       <soap12:operation
> soapAction="http://www.xxx.com/GetLatestObservationByStationAndVariable"
> style="document"/>
>       <wsdl:input>
>         <soap12:body use="literal"/>
>         <soap12:header
> message="tns:GetLatestObservationByStationAndVariableUsernameToken"
> part="UsernameToken" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap12:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>     <wsdl:operation name="GetLatestObservationsByStation">
>       <soap12:operation
> soapAction="http://www.xxx.com/GetLatestObservationsByStation"
> style="document"/>
>       <wsdl:input>
>         <soap12:body use="literal"/>
>         <soap12:header
> message="tns:GetLatestObservationsByStationUsernameToken"
> part="UsernameToken" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap12:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>     <wsdl:operation name="GetObservationsByStationAndVariable">
>       <soap12:operation
> soapAction="http://www.xxx.com/GetObservationsByStationAndVariable"
> style="document"/>
>       <wsdl:input>
>         <soap12:body use="literal"/>
>         <soap12:header
> message="tns:GetObservationsByStationAndVariableUsernameToken"
> part="UsernameToken" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap12:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>     <wsdl:operation name="GetObservationsByStation">
>       <soap12:operation
> soapAction="http://www.xxx.com/GetObservationsByStation"
> style="document"/>
>       <wsdl:input>
>         <soap12:body use="literal"/>
>         <soap12:header
> message="tns:GetObservationsByStationUsernameToken"
> part="UsernameToken" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap12:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>   </wsdl:binding>
>   <wsdl:service name="xxx_x0020_Web_x0020_Service">
>     <wsdl:documentation
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">This web service
> provides real-time data data.</wsdl:documentation>
>     <wsdl:port name="xxx_x0020_Web_x0020_ServiceSoap"
> binding="tns:xxx_x0020_Web_x0020_ServiceSoap">
>       <soap:address location="http://yyy.xxx.net/WebSite/dataData.asmx"/>
>     </wsdl:port>
>     <wsdl:port name="xxx_x0020_Web_x0020_ServiceSoap12"
> binding="tns:xxx_x0020_Web_x0020_ServiceSoap12">
>       <soap12:address location="http://yyy.xxx.net/WebSite/dataData.asmx"/>
>     </wsdl:port>
>   </wsdl:service>
> </wsdl:definitions>
>
> 2007/12/7, alessio.soldano at jboss.com <do-not-reply at jboss.com>:
> > "leandroal" wrote : Do you say something like this:
> >   |
> >   |         Map<String, Object> requestContext = ((BindingProvider)serviceSoap).getRequestContext();
> >   |         requestContext.put(BindingProvider.USERNAME_PROPERTY, "OULU");
> >   |         requestContext.put(BindingProvider.PASSWORD_PROPERTY, "810420_A");
> >   |
> >   | If yes, I did and it doesn't work.
> >   |
> >   | When I run wsconsumer against the wsdl, it generated the UsernameToken java class and I can instantiate it:
> >   |
> >   |         UsernameToken usernameToken = new UsernameToken();
> >   |         usernameToken.setUsername("xxx");
> >   |         usernameToken.setPassword("yyyy");
> >   |
> >   | But how to add this object into the SOAP Header?
> >   |
> >   | Thanks,
> >   | Leandro.
> >   |
> >   |
> > OK, please post here the wsdl of the service you would like to call. It seems that the endpoint you're hitting is not using the standard ws-security + username token. It's using a custom soap header named the same way (but with different namespace, yesterday I didn't noticed it, sorry).
> > If you can't change the service contract (using the standard security would of course be better), you issue becomes "how do I set up a custom soap header?". Setting a soap header should be quite straightforward, however it seems you have an issue with the tools, since wsconsume is not correctly creating the parameter corresponding to the header. Please post here the wsdl so that we can try to understand why.
> >
> >
> > View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4111121#4111121
> >
> > Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4111121
> > _______________________________________________
> > jboss-user mailing list
> > jboss-user at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/jboss-user
> >
>
>
> --
> Leandro Melo de Sales.
> Pervasive and Embedded Computing Laboratory
> BRisa and E-Phone Projects Manager
> Network Admin @ http://embedded.ufcg.edu.br/indexen.html
> +55 83 3310-1404 (extension 208)
>
> O especialista é alguém que conhece sempre mais sobre cada vez menos e
> termina por saber tudo sobre nada!
>


-- 
Leandro Melo de Sales.
Pervasive and Embedded Computing Laboratory
BRisa and E-Phone Projects Manager
Network Admin @ http://embedded.ufcg.edu.br/indexen.html
+55 83 3310-1404 (extension 208)

O especialista é alguém que conhece sempre mais sobre cada vez menos e
termina por saber tudo sobre nada!




More information about the jboss-user mailing list