我是不熟悉使用Spring Boot进行SOAP Webserivce的。调用.wsdl时,在浏览器中正常显示wsdl文件。但是,当调用.asmx linkm时,它什么也没显示,
wsdl看起来像:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://tempuri.org/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
targetNamespace="http://tempuri.org/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://tempuri.org/">
<s:element name="Create">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="request"
type="tns:Request" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="Request">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="ID"
type="s:int" />
<s:element minOccurs="0" maxOccurs="1"
name="TransactionType" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Name"
type="s:string" />
</s:sequence>
</s:complexType>
<s:element name="Result">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Result"
type="tns:Response" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="Response">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="StatusCode"
type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="ID"
type="s:int" />
<s:element minOccurs="0" maxOccurs="1"
name="ErrorMessage" type="s:string" />
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="CreateSoapIn">
<wsdl:part name="parameters" element="tns:Create" />
</wsdl:message>
<wsdl:message name="CreateSoapOut">
<wsdl:part name="parameters" element="tns:Result" />
</wsdl:message>
<wsdl:portType name="ServiceSoap">
<wsdl:operation name="Create">
<wsdl:input message="tns:CreateSoapIn" />
<wsdl:output message="tns:CreateSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="ServiceHttpGet" />
<wsdl:portType name="ServiceHttpPost" />
<wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
<soap:binding
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Create">
<soap:operation soapAction="http://tempuri.org/Create"
style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
<soap12:binding
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Create">
<soap12:operation
soapAction="http://tempuri.org/Create" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ServiceHttpGet"
type="tns:ServiceHttpGet">
<http:binding verb="GET" />
</wsdl:binding>
<wsdl:binding name="ServiceHttpPost"
type="tns:ServiceHttpPost">
<http:binding verb="POST" />
</wsdl:binding>
<wsdl:service name="Service">
<wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
<soap:address
location="http://localhost:9060/Service.asmx" />
</wsdl:port>
<wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
<soap12:address
location="http://localhost:9060/Service.asmx" />
</wsdl:port>
<wsdl:port name="ServiceHttpGet"
binding="tns:ServiceHttpGet">
<http:address
location="http://localhost:9060/Service.asmx" />
</wsdl:port>
<wsdl:port name="ServiceHttpPost"
binding="tns:ServiceHttpPost">
<http:address
location="http://localhost:9060/Service.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我的Web服务配置文件如下: WebserviceConfig.java
@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean<Servlet> messageDispatcherServlet(
ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean<>(servlet, "/*");
}
@Bean(name = "service")
public Wsdl11Definition defaultWsdl11Definition() {
SimpleWsdl11Definition wsdl11Definition = new SimpleWsdl11Definition();
wsdl11Definition.setWsdl(new ClassPathResource("/wsdl/service.wsdl"));
return wsdl11Definition;
}
}
我是SOAP Web服务的新手,请帮助。当我从SOAP UI调用此api时,它的工作正常,我可以创建请求并获得响应。但是我的问题是,为什么我致电http://localhost:9060/Service.asmx
时会显示错误页面