2016-10-02 4 views
0

お願いします。私はtomcatにデプロイしたシンプルなSOAPサービスを作成しました。コードは、私は、SOAP Webサービスエラー:予期しない要素名:expected = expectedName、actual:{http:// services /} expectedName

package services; 

import java.util.ArrayList; 
import javax.jws.WebService; 
import list.names; 

@WebService(endpointInterface="services.servicesInterface") 
public class servicesImpl implements servicesInterface{ 

public String createOperation(String name) { 
    System.out.println("CREATE " + name + "\n"); 
    return name; 
}} 

とその実装クラス

package services; 
import java.util.ArrayList; 

import javax.jws.WebParam; 
import javax.jws.WebResult; 
import javax.jws.WebService; 
import javax.jws.soap.SOAPBinding; 
import javax.jws.soap.SOAPBinding.Style; 

@SOAPBinding(style=Style.RPC) 
@WebService(wsdlLocation="http://localhost:8080/WS/soap") 
public interface servicesInterface { 

@WebResult(partName="name") 
String createOperation(@WebParam(partName="name", targetNamespace="/http://services/") String name); 
} 

以下のいずれかが、生成されたWSDLは、それをテストするために、私のブラウザからWizdlerを使用して、今

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://services/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://services/" name="servicesImplService"> 
<types/> 
<message name="createOperation"> 
<part name="name" type="xsd:string"/> 
</message> 
<message name="createOperationResponse"> 
<part name="name" type="xsd:string"/> 
</message> 
<portType name="servicesInterface"> 
<operation name="createOperation" parameterOrder="name"> 
<input message="tns:createOperation"/> 
<output message="tns:createOperationResponse"/> 
</operation> 
</portType> 
<binding name="servicesImplPortBinding" type="tns:servicesInterface"> 
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
<operation name="createOperation"> 
<soap:operation soapAction=""/> 
<input> 
<soap:body use="literal" namespace="http://services/"/> 
</input> 
<output> 
<soap:body use="literal" namespace="http://services/"/> 
</output> 
</operation> 
</binding> 
<service name="servicesImplService"> 
<port name="servicesImplPort" binding="tns:servicesImplPortBinding"> 
<soap:address location="http://localhost:8080/WS/soap"/> 
</port> 
</service> 
</definitions> 

に従うということです以下の要請があります。

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> 
    <Body> 
     <createOperation xmlns="http://services/"> 
      <name>JonDoe</name> 
     </createOperation> 
    </Body> 
</Envelope> 

と私はこれを得るエラー:私は2日間修正しようとしている。

<?xml version="1.0" ?> 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <soapenv:Body> 
     <soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
      <faultcode>soapenv:Server</faultcode> 
      <faultstring>unexpected element name: expected=name, actual: {http://services/}name</faultstring> 
     </soapenv:Fault> 
    </soapenv:Body> 
</soapenv:Envelope> 

ありがとうございます。

PS:私はドキュメント「@SOAPBinding(スタイル= Style.DOCUMENT)」にsoapBindingのスタイルを変更しようとすると、ところで、私もこのエラーが出る:

org.apache.catalina.core.StandardContext listenerStart 
GRAVE: Exception sending context initialized event to listener instance of class com.sun.xml.ws.transport.http.servlet.WSServletContextListener 
WSSERVLET11: failed to parse runtime descriptor: class: services.jaxws.CreateOperation could not be found 
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:130) 
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) 
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3828) 
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:291) 
at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5616) 
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1377) 
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1381) 
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1381) 
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1349) 
at java.lang.Thread.run(Unknown Source) 
Caused by: class: services.jaxws.CreateOperation could not be found 
at com.sun.xml.ws.modeler.RuntimeModeler.getClass(RuntimeModeler.java:269) 
at com.sun.xml.ws.modeler.RuntimeModeler.processDocWrappedMethod(RuntimeModeler.java:558) 
at com.sun.xml.ws.modeler.RuntimeModeler.processMethod(RuntimeModeler.java:505) 
at com.sun.xml.ws.modeler.RuntimeModeler.processClass(RuntimeModeler.java:353) 
at com.sun.xml.ws.modeler.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:249) 
at com.sun.xml.ws.server.RuntimeEndpointInfo.createModel(RuntimeEndpointInfo.java:180) 
at com.sun.xml.ws.server.RuntimeEndpointInfo.init(RuntimeEndpointInfo.java:326) 
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.createModelAndMetadata(WSServletContextListener.java:203) 
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:119) 
... 11 more 

あなたはなぜ私に言うことができますそれは起こり、それはどういう意味ですか?もう一度ありがとう。

答えて

0

ここにウィズラーの著者。 wizdlerは、http://services/名前空間のname要素を生成しました。この要素は、デフォルトの名前空間(空の名前空間)に存在する必要があります。これはまた、エラーメッセージが言うことを試みているものです:unexpected element name: expected=name, actual: {http://services/}name

は、空の文字列に name要素の名前空間を設定し、これを修正するには、次の

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> 
    <Body> 
     <createOperation xmlns="http://services/"> 
      <name xmlns="">JonDoe</name> 
     </createOperation> 
    </Body> 
</Envelope> 

をこのことができます場合は、ここで新しい問題を追加することができます。https://github.com/pepri/wizdler/issues

+0

それが動作します。ありがとうございました。しかし、一つのこと:私は多くの属性を持つobjetを持っていると、このソリューションは時間がかかりすぎる可能性があります。それを自動的に行うには、Java Webクラスで何を使用すべきですか?私は@WebParam(partName = "name"、targetNamespace = "")を試しましたが、wizdlerのxmlは変更されません。 – user3550446

関連する問題