gpt4 book ai didi

java - Spring-WS WSDL生成问题

转载 作者:搜寻专家 更新时间:2023-11-01 01:09:20 25 4
gpt4 key购买 nike

我正在尝试制作一个非常简单的 Web 服务,但在使 spring 生成正确的 wsdl 时遇到了一些困难。我已尽力从这个 spring tutorial 中复制示例.如果有人知道我做错了什么,我将非常感谢您的帮助。

本质上,有一个名为 IncidentHeaderEndpoint 的端点(目前没有任何功能)。我希望调用客户端以以下形式发送 xml 请求:

<browseIncidents>
<responsibleManager>foo</responsibleManager>
</browseIncidents>

我的端点看起来像这样:

public class IncidentHeaderEndpoint extends AbstractJDomPayloadEndpoint {
XPath respMgrExpression;

public IncidentHeaderEndpoint() {
Namespace namespace = Namespace.getNamespace("trust-service", "http://act-informatics.co.uk/trust-service/schemas");
try {
respMgrExpression = XPath.newInstance("//trust-service:StartDate");
respMgrExpression.addNamespace(namespace);
} catch (JDOMException e) {
e.printStackTrace();
}
}
protected Element invokeInternal(Element request) throws Exception {
String respMgr = respMgrExpression.valueOf(request);
return null;
}
}

当我在 tomcat 中部署时,我收到以下警告:

14-Oct-2010 13:08:43 org.springframework.ws.wsdl.wsdl11.provider.DefaultMessagesProvider addMessages
WARNING: No messages were created, make sure the referenced schema(s) contain elements
14-Oct-2010 13:08:43 org.springframework.ws.wsdl.wsdl11.provider.AbstractPortTypesProvider createOperations
WARNING: No operations were created, make sure the WSDL contains messages

这是我的 Spring 配置:

<!-- TRUST WEB SERVICES -->
<bean id="incidentHeaderEndpoint" class="co.uk.act.cics.ws.IncidentHeaderEndpoint" />

<!-- Routing Mapping -->
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
<property name="mappings">
<props>
<prop key="{http://act-informatics.co.uk/trust-service/schemas}BrowseIncidents">incidentHeaderEndpoint</prop>
</props>
</property>
<property name="interceptors">
<bean
class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" />
</property>
</bean>

<!-- WSDL Generation -->
<bean id="browse" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
<property name="schema" ref="trust-schema" />
<property name="portTypeName" value="TrustService" />
<property name="locationUri" value="http://localhost:8080/trust-service/browseIncidents/" />
<property name="targetNamespace" value="http://act-informatics.co.uk/trust-service/definitions"/>
</bean>

<bean id="trust-schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/WEB-INF/trust-service.xsd" />
</bean>

这是我的架构 - WEB-INF/trust-service.xsd:

<?xml version="1.0" encoding="UTF-8"?>`
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://act-informatics.co.uk/trust-service/schemas" xmlns:schemas="http://act-informatics.co.uk/trust-service/schemas">
<xs:element name="browseIncidents">
<xs:complexType>
<xs:sequence>
<xs:element name="responsibleManager" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

这是位于 http://localhost:8080/trust-service/browseIncidents/browse.wsdl 的有问题的 WSDL :

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:sch="http://act-informatics.co.uk/trust-service/schemas" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://act-informatics.co.uk/trust-service/definitions" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://act-informatics.co.uk/trust-service/definitions">
<wsdl:types>
<xs:schema xmlns:schemas="http://act-informatics.co.uk/trust-service/schemas" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://act-informatics.co.uk/trust-service/schemas">
<xs:element name="browseIncidents">
<xs:complexType>
<xs:sequence>
<xs:element name="responsibleManager" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:portType name="TrustService">
</wsdl:portType>
<wsdl:binding name="TrustServiceSoap11" type="tns:TrustService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
</wsdl:binding>
<wsdl:service name="TrustServiceService">
<wsdl:port binding="tns:TrustServiceSoap11" name="TrustServiceSoap11">
<soap:address location="http://localhost:8080/trust-service/browseIncidents/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

最佳答案

您的 xsd 中的输入和输出元素名称应具有后缀 Request 和 Response。那么只有spring-ws会把它识别为输入输出参数。

如果您有元素 OrderRequest 和 OrderResponse,将创建名称为 Order 的操作,输入和输出为 OrderRequest 和 OrderResponse

关于java - Spring-WS WSDL生成问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3933106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com