Hi,

I'd like to ask for some help getting started with a Camel SOAP Consumer.
I've tried following some recipes but cannot get off square one.


Firstly, I have a WSDL and can generate a request using SoapUI that works.
It gets the results that I want. The generated request is simple enough.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xf="http://xml.rothco.com/Xmlfeed/";>
   <soapenv:Header>
      <xf:AuthHeader>
         <!--Optional:-->
         <xf:Rothcoid>ABC</xf:Rothcoid>
         <!--Optional:-->
         <xf:Email>t...@test.com</xf:Email>
         <!--Optional:-->
         <xf:PassWord>XXXXXX</xf:PassWord>
      </xf:AuthHeader>
   </soapenv:Header>
   <soapenv:Body>
      <xf:GetAllItemsAndItemAttributes/>
   </soapenv:Body>
</soapenv:Envelope>

Incidentally, none of the AuthHeader values are optional, but that is what
SoapUI gives me (Values are not real.)

The response is simply a listing of products.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="
http://www.w3.org/2001/XMLSchema";>
   <soap:Body>
      <GetAllItemsAndItemAttributesResponse xmlns="
http://xml.rothco.com/Xmlfeed/";>
         <GetAllItemsAndItemAttributesResult>
            <ROOT xmlns="">
               <ITEM ItemID="11692" VariantID="1" Description="##CATALOGUE
ONLY" Category="MISC" CountryOfOrigin="USA" Sort_Order="" Color="" Size=""
Status="0" AvailableQty="99+" MESSAGE="" Weight="1.50"
WeightUnitOfMeasure="LBS" RothcoWholesaleListPrice="0.00" Sell_UOM="EA"
CasePrice="0.00" CasePACK="N/A" UPC="" ETA=""/>
               <ITEM ItemID="11693" VariantID="1" Description="*CATALOG
&amp; P/L" Category="MISC" CountryOfOrigin="USA" Sort_Order="" Color=""
Size="" Status="0" AvailableQty="18" MESSAGE="" Weight="2.00"
WeightUnitOfMeasure="LBS" RothcoWholesaleListPrice="0.00" Sell_UOM="EA"
CasePrice="0.00" CasePACK="N/A" UPC="" ETA=""/>
...
...
...

Now when I try to get the same result using Camel I cannot get very far. I
generate the Java code using the maven archetype configured as follows:

            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>

<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>

<wsdl>${basedir}/src/main/resources/wsdl/hello_world.wsdl</wsdl>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

This generates a client class with gives me the following error:

 Invoking getAllItemsAndItemAttributes...
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Server was
unable to process request. ---> Object reference not set to an instance of
an object.
    at
com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
    at
com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111)
    at
com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
    at
com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
    at $Proxy30.getAllItemsAndItemAttributes(Unknown Source)
    at
com.rothco.xml.xmlfeed.XmlFeedSoap_XmlFeedSoap_Client.main(XmlFeedSoap_XmlFeedSoap_Client.java:53)

My interpretation of this is that there is a problem with the SOAP request
that is being created.

A few questions:

(1) Is there more detail on this error that I am not seeing?
(2) On looking at the code generated I cannot figure out how the AuthHeader
class gets used in building a SOAP request. Maybe its not being added to
the request and this is the cause of the problem, the error message would
seem to suggest that might be so, there's not much else to be done but set
the header!

Is there an Camel example where the <soapenv:Header> gets configured via an
Spring XML context file? I'd like to be able to set the properties for
account authorisation that way. Maybe I have to create a bean definition to
do that?

I though this would be easy, after having used SoapUI so painlessly, and
have spent most of the day looking for answers/examples to help me
understand.

Thanks
Steve Cameron

Reply via email to