【问题标题】:Duplicated MTOM policy on Weblogic 12.1.3Weblogic 12.1.3 上的重复 MTOM 策略
【发布时间】:2016-03-22 05:24:23
【问题描述】:

我正在使用 JAX-WS 在 weblogic 12.1.3 上使用 MTOM 开发下载服务。部署后,我的 wsdl 添加了两个“MTOM”策略:

<definitions targetNamespace="http://schemas.test.pl/Test/001/2015/12/001" name="TestMTOM">
<wsp:UsingPolicy wsu:Required="true"/>
<wsp1_2:Policy wsu:Id="Mtom.xml">
    <ns0:OptimizedMimeSerialization/>
</wsp1_2:Policy>
<wsp:UsingPolicy wssutil:Required="true"/>
<wsp1_2:Policy wssutil:Id="Mtom.xml">
    <ns1:OptimizedMimeSerialization/>
</wsp1_2:Policy>
<wsp:Policy wssutil:Id="TestMTOM_portBinding_MTOM_Policy-TestMTOM_portBinding_MTOM_Policy">
    <ns2:OptimizedMimeSerialization wsp:Optional="true"/>
</wsp:Policy>
<types>
    <xsd:schema>
        <xsd:import namespace="http://schemas.test.pl/Test/199/2014/07/001" schemaLocation="http://localhost:7001/TestWebservice/TestMTOM?xsd=1"/>
    </xsd:schema>
    <xsd:schema>
        <xsd:import namespace="http://schemas.test.pl/Test/301/2015/12/001" schemaLocation="http://localhost:7001/TestWebservice/TestMTOM?xsd=2"/>
    </xsd:schema>
    <xsd:schema>
        <xsd:import namespace="http://schemas.test.pl/Test/302/2015/12/001" schemaLocation="http://localhost:7001/TestWebservice/TestMTOM?xsd=3"/>
    </xsd:schema>
</types>
<message name="ReadPrintFile">
    <part name="requestBody" element="ns3:Document"/>
</message>
<message name="ReadPrintFileResponse">
    <part name="responseBody" element="ns4:Document"/>
</message>
<message name="FaultMessage">
    <part name="fault" element="ns5:Document"/>
</message>
<portType name="TestMTOM_portType">
    <operation name="ReadPrintFile">
        <input wsam:Action="http://schemas.test.pl/Test/TestMTOM/ReadPrintFile" message="tns:ReadPrintFile"/>
        <output wsam:Action="http://schemas.test.pl/Test/001/2015/12/001/TestMTOM_portType/ReadPrintFileResponse" message="tns:ReadPrintFileResponse"/>
        <fault message="tns:FaultMessage" name="FaultMessage" wsam:Action="http://schemas.test.pl/Test/001/2015/12/001/TestMTOM_portType/ReadPrintFile/Fault/FaultMessage"/>
    </operation>
</portType>
<binding name="TestMTOM_portBinding" type="tns:TestMTOM_portType">
    <wsp:PolicyReference URI="#Mtom.xml"/>
    <wsp:PolicyReference URI="#TestMTOM_portBinding_MTOM_Policy-TestMTOM_portBinding_MTOM_Policy"/>
    <wsp:PolicyReference URI="#Mtom.xml"/>
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="ReadPrintFile">
        <soap:operation soapAction="http://schemas.test.pl/Test/TestMTOM/ReadPrintFile"/>
        <input>
            <soap:body use="literal"/>
        </input>
        <output>
            <soap:body use="literal"/>
        </output>
        <fault name="FaultMessage">
            <soap:fault name="FaultMessage" use="literal"/>
        </fault>
    </operation>
</binding>
<service name="TestMTOM">
    <port name="TestMTOM_port" binding="tns:TestMTOM_portBinding">
        <soap:address location="http://localhost:7001/TestWebservice/TestMTOM"/>
    </port>
</service>

尝试连接到此类已部署的 Web 服务出现错误:

com.sun.xml.internal.ws.policy.PolicyException: WSP1020: Found two policies in one document with the same id: "Mtom.xml".
       at com.sun.xml.internal.ws.policy.jaxws.SafePolicyReader$PolicyRecord.setUri(SafePolicyReader.java:113)
       at com.sun.xml.internal.ws.policy.jaxws.SafePolicyReader.readPolicyElement(SafePolicyReader.java:272)
       at com.sun.xml.internal.ws.policy.jaxws.PolicyWSDLParserExtension.definitionsElements(PolicyWSDLParserExtension.java:413)
       at com.sun.xml.internal.ws.wsdl.parser.DelegatingParserExtension.definitionsElements(DelegatingParserExtension.java:80)
       at com.sun.xml.internal.ws.wsdl.parser.FoolProofParserExtension.definitionsElements(FoolProofParserExtension.java:85)
       at com.sun.xml.internal.ws.wsdl.parser.WSDLParserExtensionFacade.definitionsElements(WSDLParserExtensionFacade.java:123)
       at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(RuntimeWSDLParser.java:464)
       at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:234)
       at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:194)
       at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:163)
       at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:348)
       at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:306)
       at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:215)
       at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:196)
       at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:192)
       at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
       at javax.xml.ws.Service.<init>(Service.java:77)
       at javax.xml.ws.Service.create(Service.java:707)
       at com.test.ws.mtom.TestMTOMClient.main(TestMTOMClient.java:57)

任何想法都会被欣赏。

服务实现注释如下:

@javax.xml.ws.soap.MTOM
@javax.jws.WebService(
                      serviceName = "TestMTOM",
                      portName = "TestMTOM_port",
                      targetNamespace = "http://schemas.test.pl/test/001/2015/12/001",
                      wsdlLocation = "file:/c:/TestWebservice/wsdl/TestMTOM.soap12/TestMTOM.wsdl",
                      endpointInterface = "pl.test.schemas.smw2._001._2015._12._001.TestMTOMPortType")
public class TestMTOMPortTypeImpl implements TestMTOMPortType {
}

客户端在尝试时遇到错误:

URL url = new URL("http://localhost:7001/TestWebservice/TestMTOM?WSDL");
QName qname = new QName("http://schemas.test.pl/test/001/2015/12/001", "TestMTOM");
Service service = TestMTOM.create(url, qname);

【问题讨论】:

    标签: java web-services weblogic12c mtom


    【解决方案1】:

    我找到了解决办法。

    我准备了 webservices.xml 和我的 web 服务的定义(虽然它不是必需的)并将它放在 WEB-INF 目录中。 使用这样的文件进行部署解决了这个问题。 现在部署的 wsdl 只有一个 MTOM 策略 :-)

    【讨论】:

      【解决方案2】:

      就我而言,删除 @javax.jws.WebService 上的 wsdlLocation 属性会有所帮助

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多