2010-04-29 48 views
2

我得到這個錯誤:未找到端點映射[SaajSoapMessage {} http://mycompany/coolservice/specs ChangePerson]沒有終點映射發現...,使用SpringWS,JAXB的Marshaller

以下是我WS的配置文件:

<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping"> 
    <description>An endpoint mapping strategy that looks for @Endpoint and @PayloadRoot annotations.</description> 
</bean> 
<bean class="org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter"> 
    <description>Enables the MessageDispatchServlet to invoke methods requiring OXM marshalling.</description> 
    <constructor-arg ref="marshaller"/> 
</bean> 

<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> 
    <property name="contextPaths"> 
    <list> 
     <value>org.company.xml.persons</value> 
     <value>org.company.xml.person_allextensions</value> 
     <value>generated</value> 
    </list> 
    </property> 
</bean> 


<bean id="persons" class="com.easy95.springws.wsdl.wsdl11.MultiPrefixWSDL11Definition"> 
    <property name="schemaCollection" ref="schemaCollection"/>            
    <property name="portTypeName" value="persons"/>         
    <property name="locationUri" value="/ws/personnelService/"/>        
    <property name="targetNamespace" value="http://mycompany/coolservice/specs/definitions"/>  
</bean> 

<bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">     
    <property name="xsds"> 
    <list> 
     <value>/DataContract/Person-AllExtensions.xsd</value> 
     <value>/DataContract/Person.xsd</value> 
    </list> 
    </property> 
    <property name="inline" value="true"/>  
</bean> 

我然後將以下文件:

public interface MarshallingPersonService { 

public final static String NAMESPACE = "http://mycompany/coolservice/specs"; 
public final static String CHANGE_PERSON = "ChangePerson"; 

public RespondPersonType changePerson(ChangePersonType request); 
} 

@Endpoint 
    public class PersonEndPoint implements MarshallingPersonService { 

    @PayloadRoot(localPart=CHANGE_PERSON, namespace=NAMESPACE) 
    public RespondPersonType changePerson(ChangePersonType request) { 
     System.out.println("Received a request, is request null? " + (request == null ? "yes" : "no")); 
     return null;   
    } 

} 

我對WebServices非常陌生,對註釋不太滿意。我正在關注在springws中設置jaxb編組的教程。我寧願使用xml映射比註釋,雖然現在我收到錯誤消息。

編輯:ChangePersonType

@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "ChangePersonType", propOrder = { 
"applicationArea", 
"dataArea" 
}) 
public class ChangePersonType { 

@XmlElement(name = "ApplicationArea", namespace = "http://mycompany/coolservice/specs", required = true) 
protected TransApplicationAreaType applicationArea; 
@XmlElement(name = "DataArea", namespace = "http://mycompany/coolservice/specs", required = true) 
protected DataArea dataArea; 
@XmlAttribute(required = true) 
@XmlJavaTypeAdapter(NormalizedStringAdapter.class) 
protected String releaseID; 
@XmlAttribute 
@XmlJavaTypeAdapter(NormalizedStringAdapter.class) 
protected String versionID; 

--The其餘都是getter和setter。

+0

我也紛紛出手在黑暗中設置的命名空間不斷爲 「{HTTP:// myCompany中/ coolservice /規格} ChangePerson」,但沒有工作。 任何想法/建議這些註釋是如何工作來選擇ChangePerson的,以及我在做什麼錯誤...? – Saky 2010-04-29 09:50:10

+0

您是否也可以添加'ChangePersonType'的源代碼,或者至少可以添加它的前幾行。 – skaffman 2010-04-29 09:54:24

+0

完成後,它是由jaxb xjc編譯器生成的。 – Saky 2010-04-29 11:02:43

回答

1

我解決了它。終點類和返回變量的參數必須包裝在JAXBElement中,例如JAXBElement。

原因是

The classes generated by JAXB2 from your schema come in two flavors: those that have a @XmlRootElement annotation, which can be used directly as either parameter or response, and those who haven't. Those classes which haven't got this annotation need to be wrapped in a JAXBElement.

Besides the generated classes from your schema, JAXB2 also generates an ObjectFactory class, which clarifies the use of JAXBElement. There are some factory methods is there, which illustrate how you can use the various schema types.

Arjen Poutsma h ttp://forum.springsource.org/showthread.php?t=49817