这是我的WSDL文件:就是那个03版本可以编译,而05版本不能编译的那个:
<wsdl:types>
<schema targetNamespace="
http://apache.org/callback"
xmlns="
http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/"
xmlns:jaxb="
http://java.sun.com/xml/ns/jaxb"
jaxb:version="2.0">
<xsd:import namespace="
http://www.w3.org/2005/08/addressing"
schemaLocation="/schemas/wsdl/ws-addr.xsd"/>
<element name="callback_message" type="xsd:string"/>
<element name="RegisterCallback"
type="references:EndpointReferenceType"/>
<element name="returnType" type="xsd:string"/>
<element name="version" type="xsd:string"/>
</schema>
</wsdl:types>
<wsdl:message name="server_sayHi">
<wsdl:part element="tns:version" name="xHeader"/>
<wsdl:part element="tns:callback_message" name="return_message"/>
</wsdl:message>
<wsdl:message name="register_callback">
<wsdl:part element="tns:RegisterCallback" name="callback_object"/>
</wsdl:message>
<wsdl:message name="returnMessage">
<wsdl:part element="tns:returnType" name="the_return"/>
</wsdl:message>
<wsdl:portType name="CallbackPortType">
<wsdl:operation name="ServerSayHi">
<wsdl:input message="tns:server_sayHi" name="ServerSayHiRequest"/
>
<wsdl:output message="tns:returnMessage"
name="ServerSayHiResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="ServerPortType">
<wsdl:operation name="RegisterCallback">
<wsdl:input message="tns:register_callback"
name="RegisterCallbackRequest"/>
<wsdl:output message="tns:returnMessage"
name="RegisterCallbackResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CallbackPortType_SOAPBinding"
type="tns:CallbackPortType">
<soap:binding style="document" transport="
http://schemas.xmlsoap.org/
soap/http"/>
<wsdl:operation name="ServerSayHi">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:header message="tns:ServerSayHiRequest" part="xHeader"
use="literal" />
<soap:body parts="return_message" use="literal" />
</wsdl:input>
<wsdl:output name="ServerSayHiResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ServerPortType_SOAPBinding"
type="tns:ServerPortType">
<soap:binding style="document" transport="
http://schemas.xmlsoap.org/
soap/http"/>
<wsdl:operation name="RegisterCallback">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="RegisterCallbackRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="RegisterCallbackResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CallbackService">
<wsdl:port binding="tns:CallbackPortType_SOAPBinding"
name="CallbackPort">
<soap:address location="
http://localhost:9005/CallbackContext/
CallbackPort"/>
</wsdl:port>
</wsdl:service>
<wsdl:service name="SOAPService">
<wsdl:port binding="tns:ServerPortType_SOAPBinding" name="SOAPPort">
<soap:address location="
http://localhost:9000/SoapContext/
SoapPort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我的本意是通过头中的VERSION信息来区分不同的服务
下面是截取器的代码:
public class MediatorInInterceptor extends
AbstractEndpointSelectionInterceptor {
public MediatorInInterceptor() {
super(Phase.POST_STREAM);
addBefore(StaxInInterceptor.class.getName());
}
@Override
protected Endpoint selectEndpoint(Message message, Set<Endpoint>
eps) {
InputStream is =
message.getContent(InputStream.class);
if (is == null) {
return null;
}
try {
CachedOutputStream bos = new CachedOutputStream(4096);
IOUtils.copy(is, bos);
is.close();
message.setContent(InputStream.class,
bos.getInputStream());
String encoding = (String)message.get(Message.ENCODING);
XMLStreamReader xsr;
xsr =
StaxInInterceptor.getXMLInputFactory(message).createXMLStreamReader(bos.getInputStream(),
encoding);
while (true) {
xsr.nextTag();
if ("version".equals(xsr.getName().getLocalPart())) {
break;
}
}
String version = xsr.getElementText();
for (Endpoint ep : eps) {
if(version != null){
if (version.equals(ep.get("CallBackID"))) {
System.out.println("version from server: " + version);
return ep;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
我想知道为什么回有上面那种奇怪的错误?