0

質問とスタック トレース

このドキュメント(w3.org から) では、「tns」プレフィックスの jaxws の従来の使用法を次のように説明しています。

「この名前空間」(tns) プレフィックスは、現在のドキュメントを参照するための規則として使用されます。


tns私の質問は、このプレフィックスが実際に jaxws によって予約されている かどうかに主に集中しています。以下に含まれるスキーマを使用して XJC から生成された POJO がいくつかあります。これらの生成された POJO に加えて、既存のpackage-info.javaファイルを以下に示すものに置き換えました。このパッケージ情報。javaファイルは基本的に、XML スキーマに記述された名前空間と接頭辞の情報を保持します。Tomcat で Web サービスを開始すると、次のエラーが表示されます。これは、jaxws が使用tnsを望んでいることを示しているようで、名前空間http://www.offender.comで既に使用されているため、IllegalArgumentException がスローされます。tnsは宣言されていますが、使用されていないことに注意してください。他の誰かがこの問題を経験しましたか? 私は想像するtnsは一般的に使用される名前空間なのでtnspackage-info.javaでの私の明示的な使用は、ある種の偽物ですか?

SEVERE: WSSERVLET11: failed to parse runtime descriptor: java.lang.IllegalArgumentException: Prefix 'tns' is already bound to 'http://www.offender.com'
java.lang.IllegalArgumentException: Prefix 'tns' is already bound to 'http://www.offender.com'
        at com.sun.xml.txw2.StartTag.addNamespaceDecl(StartTag.java:171)
        at com.sun.xml.txw2.ContainerElement._namespace(ContainerElement.java:313)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at com.sun.xml.txw2.ContainerElement.invoke(ContainerElement.java:114)
        at sun.proxy.$Proxy92._namespace(Unknown Source)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeTo(XmlSchemaGenerator.java:636)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.access$700(XmlSchemaGenerator.java:493)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.write(XmlSchemaGenerator.java:475)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl.generateSchema(JAXBContextImpl.java:826)
        at com.sun.xml.ws.db.glassfish.JAXBRIContextWrapper.generateSchema(JAXBRIContextWrapper.java:103)
        at com.sun.xml.ws.wsdl.writer.WSDLGenerator.generateTypes(WSDLGenerator.java:457)
        at com.sun.xml.ws.wsdl.writer.WSDLGenerator.generateDocument(WSDLGenerator.java:433)
        at com.sun.xml.ws.wsdl.writer.WSDLGenerator.doGeneration(WSDLGenerator.java:330)
        at com.sun.xml.ws.db.DatabindingImpl.generateWSDL(DatabindingImpl.java:230)
        at com.sun.xml.ws.server.EndpointFactory.generateWSDL(EndpointFactory.java:553)
        at com.sun.xml.ws.server.EndpointFactory.create(EndpointFactory.java:278)
        at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:147)
        at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:574)
        at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:557)
        at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:260)
        at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:152)
        at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.parseAdaptersAndCreateDelegate(WSServletContextListener.java:131)
        at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:152)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1385)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:306)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
        at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1389)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1653)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1662)

Web サービスのデプロイメントで使用するファイル

xjc を使用して POJO を作成するスキーマ:

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2013 rel. 2 (x64) (http://www.altova.com) by Allen Strand (FAIR ISAAC & COMPANY) -->
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.offender.com" xmlns:ns1="http://www.example.com" targetNamespace="http://www.example.com" elementFormDefault="qualified">
    <element name="Example">
        <complexType>
            <sequence>
                <element name="ExampleElement" type="ns1:ExampleType"/>
            </sequence>
        </complexType>
    </element>
    <complexType name="ExampleType">
        <sequence>
            <element name="ExampleProperty" type="string"/>
        </sequence>
    </complexType>
</schema>

sun-jaxws.xml

<?xml version="1.0" encoding="UTF-8"?>
<endpoints
  xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
  version="2.0">
  <endpoint
      name="ExampleEndpoint"
      implementation="com.example.soap.ExampleEndpointImpl"
      url-pattern="/ws/runtime/eval"/>
</endpoints>

パッケージ情報.java

@javax.xml.bind.annotation.XmlSchema(
    namespace = "http://www.example.com",
    elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
    xmlns = {
        @XmlNs(prefix = "ns1",namespaceURI = "http://www.example.com"),
        @XmlNs(prefix = "tns",namespaceURI = "http://www.offender.com")
    })
package com.some.package;
import javax.xml.bind.annotation.XmlNs;

ExampleEndpoint.java インターフェイス

package com.example.soap;

import com.example.soap.SOAPFaultException;

import javax.jws.HandlerChain;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.jws.soap.SOAPBinding.Use;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;

import com.example.Example;

//Service Endpoint Interface
@WebService
@SOAPBinding(style = Style.DOCUMENT, use=Use.LITERAL) //optional
@HandlerChain(file="handler-chain.xml")
public interface ExampleEndpoint
{
    @WebMethod
    @WebResult(name="Example", targetNamespace = "http://www.example.com")
    Example eval(@WebParam(name="Example", mode=WebParam.Mode.IN, targetNamespace="http://www.example.com")
    Example in) throws SOAPFaultException;
}
4

1 に答える 1