1
votes

I am wondering if Mule will create a wsdl on a http endpoint so I can access it through soapUI. I am passing in xml with a soap envelope, like what follows. I don't have a wsdl created, but I have a flow afterwards to read and use this xml being passed in. I know with other ESB tools it's possible to say this endpoint needs to expose a wsdl, and it'll create one for you on build. Does mule do anything like this?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
    <lookup>
        <bookid>0028634748</bookid>
    </lookup>
</soapenv:Body>

Thanks for your time.

1

1 Answers

1
votes

Mule can generate a WSDL on-the-fly but it needs something to infer the WSDL from. It can be done from a pure POJO component without any need for JAX-WS annotations and is configured like this:

<flow name="bookLookupService">
    <http:inbound-endpoint address="http://localhost:8181/bls"
        exchange-pattern="request-response">
        <cxf:simple-service serviceClass="com.acme.BookLookupService" />
    </http:inbound-endpoint>
    <component class="com.acme.BookLookupServiceImpl" />
</flow>

With the following interface:

package com.acme;

public interface BookLookupService
{
    public static class BookLookup
    {
        private String bookid;

        public String getBookid()
        {
            return bookid;
        }

        public void setBookid(final String bookid)
        {
            this.bookid = bookid;
        }
    }

    public static class Book
    {
        private String bookid, name;

        public String getBookid()
        {
            return bookid;
        }

        public void setBookid(final String bookid)
        {
            this.bookid = bookid;
        }

        public String getName()
        {
            return name;
        }

        public void setName(final String name)
        {
            this.name = name;
        }
    }

    Book lookup(final BookLookup bookLookup);
}

and implementation:

package com.acme;

public class BookLookupServiceImpl implements BookLookupService
{
    public Book lookup(final BookLookup bookLookup)
    {
        final Book book = new Book();
        book.setName("LOTR");
        book.setBookid(bookLookup.getBookid());
        return book;
    }
}

The problem is that the WSDL will not conform to the expected message above, you end up with messages like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:acme="http://acme.com/" xmlns:acme1="http://acme.com">
   <soapenv:Header/>
   <soapenv:Body>
      <acme:lookup>
         <acme:arg0>
            <acme1:bookid>ABC123</acme1:bookid>
         </acme:arg0>
      </acme:lookup>
   </soapenv:Body>
</soapenv:Envelope>

If you want stricter control on the generated WSDL you'll have to use JAX-WS / JAXB annotations.