Mule 可以即时生成 WSDL,但它需要一些东西来推断 WSDL。它可以从纯 POJO 组件中完成,而无需 JAX-WS 注释,并且配置如下:
<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>
使用以下界面:
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);
}
和实施:
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;
}
}
问题是 WSDL 将不符合上面的预期消息,您最终会得到如下消息:
<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>
如果您想对生成的 WSDL 进行更严格的控制,则必须使用 JAX-WS / JAXB 注释。