开发者

Generating wsdl using Websphere and JAXB annotated service/entities

I'm trying to generate a wsdl. The service is constructed as shown below. Nothing unusual really, but I do have the Exception I want to throw, located in a separate package, thus appearing in a different namespace than the service and the entity in the generated wsdl. Retrieving the wsdl file (by http://service.example.com/?wsdl) produces this file below that does not validate, since, again, the Exception isn't in the same namespace. Is there a way to generate a wsdl that validates while at the same time having the Exception in a separate package (keep in mind that I do want to reuse the exception in other services, in other namespaces also).

package com.example.exception;

XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace="http://exception.example.com")
public class ServiceException extends Exception {


    public ServiceException() {
        super();
    }

    .....

}



package com.example.service;

public interface DoSomethingService {

    @ResponseWrapper(localName = "findResponseTag")
    public Entity find( @WebParam(name="input") String input ) throws ServiceException;

    .....
}

package com.example.service;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "http://entity.example.com")
public class Entity {

    @XmlAttribute
    private String name;

    public Entity(){

    }

    .....
}

The generated wsdl: The ServiceEx开发者_如何学运维ception referenced below is in ns4 and not tns.

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://service.example.com/"
    xmlns:SOAP11="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns4="http://exception.example.com/"
    name="DoSomethingServiceService" targetNamespace="http://service.example.com/">
<wsdl:types>
        <xs:schema xmlns:ns1="http://service.ancillary.model.vsp.com"
            xmlns:tns="http://exception.example.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://exception.example.com/" version="1.0">
            <xs:import namespace="http://exception.example.com" />
            <xs:element name="ServiceException" type="tns:ServiceException" />
            <xs:complexType name="ServiceException">

                .....

            </xs:complexType>
        </xs:schema>

    ..........

    <wsdl:portType name="DoSomethingService">
        <wsdl:operation name="find">
            <wsdl:input message="tns:find"></wsdl:input>
            <wsdl:output message="tns:findResponse"></wsdl:output>
            <wsdl:fault name="ServiceException" message="ns4:ServiceException"></wsdl:fault>
        </wsdl:operation>
    </wsdl:portType>


</wsdl:types>

.....

</wsdl:definitions>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜