cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan Moquin" <fragility...@gmail.com>
Subject Re: Adding headers to soap request
Date Tue, 11 Sep 2007 14:57:27 GMT
I always make progress after I send out a message about it... I figured out
that the confusion over the headers is because when this dependency is
missing from wsdltojava (not mentioned on the cxf website to do this), then
it won't include your header:

<dependencies>
                 <dependency>
                   <groupId>org.apache.cxf</groupId>
                   <artifactId>cxf-rt-bindings-soap</artifactId>
                   <version>${project.version}</version>
                 </dependency>
               </dependencies>

So anyhow, I'm still stuck with my error though, so I guess that wasn't my
problem:

Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
        at java.util.ArrayList.RangeCheck(ArrayList.java:546)
        at java.util.ArrayList.get(ArrayList.java:321)
        at org.apache.cxf.message.MessageContentsList.get(
MessageContentsList.java:76)
        at
org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleHeaderPart(
SoapOutInterceptor.java:179)
        at
org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart
(SoapOutInterceptor.java:124)

        at
org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(
SoapOutInterceptor.java:76)
        at
org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(
SoapOutInterceptor.java:57)

On 9/11/07, Ryan Moquin <fragility2.0@gmail.com> wrote:
>
> I'm writing this as a new message, but I'm hoping that it's answer will
> solve my other issue I'm writing about.  I think I'm having having trouble
> understanding how to add a header to my request using cxf.  In short, I have
> a WSDL that defines this element:
>
> <s:element name="AuthCredentials" type="tns:AuthCredentials"/>
>       <s:complexType name="AuthCredentials">
>         <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:complexType>
>
> and then defines a binding that uses it:
>
> <wsdl:operation name="sendNotification">
>       <soap:operation soapAction="urn://testnotification/sendNotification"
> style="document"/>
>       <wsdl:input>
>         <soap:body use="literal"/>
>         <soap:header message="tns:sendNotificationAuthCredentials"
> part="AuthCredentials" use="literal"/>
>       </wsdl:input>
>       <wsdl:output>
>         <soap:body use="literal"/>
>       </wsdl:output>
>     </wsdl:operation>
>
> When I run this WSDL through wsdltojava using -exsh true, the generated
> client classes do NOT set the header that is specified in the binding, which
> is what I thought that the -exsh is supposed to do for you.  So basically,
> I'm trying to figure out how I would add this element to my request.  Here
> is what WSDL to java generated, how do I add the AuthCredentials element to
> the messagingPort class so that my request will go through with it? All I
> get currently is an IndexOutOfBoundsException when CXF tries to create the
> header of the SOAP message to send, I'm guessing because I don't know how to
> add the header.  I looked at the CXF examples on it, but it doesn't look
> like the headers are being added as a header:
>
> public void sendNotification() {
>     NotificationService messagingService = null;
>     NotificationServicePort messagingPort = null;
>
>     messagingService = new NotificationService(wsdl, SERVICE_NAME);
>     messagingPort = messagingService.getNotificationServicePort();
>
>     System.out.println("Invoking sendNotification...");
>     java.lang.String _sendNotification_parametersVal = "";
>     javax.xml.ws.Holder<java.lang.String> _sendNotification_parameters =
> new javax.xml.ws.Holder<java.lang.String
> >(_sendNotification_parametersVal);
>     messagingPort.sendNotification(_sendNotification_parameters);
>     System.out.println("sendNotification._sendNotification_parameters=" +
> _sendNotification_parameters.value);
>   }
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message