xpath语句没有生成节点来验证spring启动soap请求

nnsrf1az  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(270)

我已经编写了一个客户端来发送soap请求消息。我使用回调添加了一个安全头标记和一个从wsdl创建的requestheader类型。代码正在创建如上所述的错误。这是客户:

public class ConfirmClient implements WebServiceMessageCallback{

    private WebServiceTemplate webServiceTemplate;

    private Jaxb2Marshaller jaxb2Marshaller;

    @Value("${cam.orch.request.username}")
    private String username;

    @Value("${cam.orch.request.password}")
    private String password;

    private final Logger log = LoggerFactory.getLogger(this.getClass());

    public ProcessUPIUCResponseType processDispatchRequest(ProcessUPIUCRequestType processRequest) {
        log.info("Attempting to marshal processUPIUCRequest type with content " + processRequest.toString());
        jaxb2Marshaller = new ConfirmConfig().marshaller();
        webServiceTemplate = new WebServiceTemplate(jaxb2Marshaller);
        try {
            return (ProcessUPIUCResponseType) webServiceTemplate.marshalSendAndReceive(Constants.CONFIRM_SOAP_URL, processRequest, this);
        }catch(SoapFaultClientException e) {
            log.error("SOAP error occurred attempting to send UPIUCSoap request to " + Constants.CONFIRM_SOAP_URL + " " + e.getMessage() + 
                    e.getMostSpecificCause() + "\n\nFault code " + e.getFaultCode() + e.getRootCause() + e.getStackTrace()+ e.getSoapFault().getName() +
                    e.getSoapFault().getFaultStringOrReason() + e.getSoapFault().getFaultDetail());
        }
        return null;
    }

    @Override
    public void doWithMessage(WebServiceMessage message) {
        try {
            SaajSoapMessage saajSoapMessage = (SaajSoapMessage)message;

            SOAPMessage soapMessage = saajSoapMessage.getSaajMessage();

            SOAPPart soapPart = soapMessage.getSOAPPart();

            SOAPEnvelope soapEnvelope = soapPart.getEnvelope();

            SOAPHeader soapHeader = soapEnvelope.getHeader();

            Name headerElementName = soapEnvelope.createName(
                    "Security",
                    "wsse",
                    "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
                    );
            SOAPHeaderElement soapHeaderElement = soapHeader.addHeaderElement(headerElementName);
            soapHeaderElement.addNamespaceDeclaration("xs", "http://www.w3.org/2001/XMLSchema");
            soapHeaderElement.addNamespaceDeclaration("tns", "http://osb.shp.com/xsd/Header");

            SOAPElement usernameTokenSOAPElement = soapHeaderElement.addChildElement("UsernameToken", "wsse");

            SOAPElement userNameSOAPElement = usernameTokenSOAPElement.addChildElement("Username", "wsse");
            log.info(this.username);
            userNameSOAPElement.addTextNode(this.username);

            SOAPElement passwordSOAPElement = usernameTokenSOAPElement.addChildElement("Password", "wsse");

            passwordSOAPElement.addTextNode(this.password);

            RequestHeaderType requestHeaderType = new ObjectFactory().createRequestHeaderType();
            requestHeaderType.setAuditLevel("1.0");
            requestHeaderType.setCallingApplicationName("com.tvg.cam.orch");
            requestHeaderType.setTransactionId("1.0");
            requestHeaderType.setVersion("1.0");
            JAXBElement headers = new ObjectFactory().createRequestHeader(requestHeaderType);
            JAXBContext context = JAXBContext.newInstance(RequestHeaderType.class);
            Marshaller marshaller = context.createMarshaller();
            marshaller.marshal(requestHeaderType, soapHeader);

        } catch (Exception e) {
            log.error("error during marshalling of the SOAP headers", e);
        }
    }
}

这将创建以下信封作为错误消息的输出:

</soapenv:Envelope>] for request [<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header>
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:tns="http://osb.shp.com/xsd/Header" xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <wsse:UsernameToken>
                <wsse:Username>'ddd'</wsse:Username>
                <wsse:Password>'1234'</wsse:Password>
            </wsse:UsernameToken>
            <ns5:requestHeaderType xmlns:ns5="http://osb.shp.com/xsd/DDUpiCAM">
                <tns:CallingApplicationName>com.tvg.cam.orch</tns:CallingApplicationName>
                <tns:TransactionId>1.0</tns:TransactionId>
                <tns:Version>1.0</tns:Version>
                <tns:AuditLevel>1.0</tns:AuditLevel>
            </ns5:requestHeaderType>
        </wsse:Security>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns3:processUPIUCRequestType xmlns:ns3="http://osb.shp.com/xsd/DDUpiCAM" xmlns:ns2="http://osb.shp.com/xsd/Header">
            <ns3:CaContractNumber>26590701</ns3:CaContractNumber>
            <ns3:CaOrderNumber>2</ns3:CaOrderNumber>
            <ns3:CaDDOrderNumber>1633131X</ns3:CaDDOrderNumber>
            <ns3:CaUpiNumber>F1234512345</ns3:CaUpiNumber>
            <ns3:CaOrderItemComponentNo>123</ns3:CaOrderItemComponentNo>
        </ns3:processUPIUCRequestType>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>]

错误消息是xpath语句没有生成要验证和soap的节点-env:faultclient.validationerrorosb validate 操作验证失败。我不确定这与什么有关,也不确定如何设置xpath进行验证。wsdl是:

<?xml version="1.0" encoding="UTF-8"?>
<con:soapui-project id="33hk3hj3khj3" activeEnvironment="Default" name="DDUpiCAM" resourceRoot="" soapui-version="5.2.1" xmlns:con="http://revive.com/soapui/config"><con:settings/><con:interface xsi:type="con:WsdlInterface" id="334g4hj3g4" wsaVersion="NONE" name="DDUpiCAM_Binding" type="wsdl" bindingName="{http://osb.shp.com/DDUpiCAM}DDUpiCAM_Binding" soapVersion="1_1" anonymous="optional" definition="https://wsi-ppt2.shp.com/dv/DDUpiCAM/ProxyService/DDUpiCAMPS?wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:settings/><con:definitionCache type="TEXT" rootPart="https://wsi-ppt2.shp.com/dv/DDUpiCAM/ProxyService/DDUpiCAMPS?wsdl"><con:part><con:url>https://wsi-ppt2.shp.com/dv/DDUpiCAM/ProxyService/DDUpiCAMPS?wsdl</con:url><con:content><![CDATA[<WL5G3N0:definitions targetNamespace="http://osb.shp.com/DDUpiCAM" xmlns:WL5G3N0="http://schemas.xmlsoap.org/wsdl/" xmlns:WL5G3N1="http://osb.shp.com/xsd/Header" xmlns:WL5G3N2="http://osb.shp.com/xsd/DDUpiCAM" xmlns:WL5G3N3="http://osb.shp.com/DDUpiCAM" xmlns:WL5G3N4="http://schemas.xmlsoap.org/wsdl/soap/">
<con:soapui-project id="hh3khj3k3hj3" activeEnvironment="Default" name="DDUpiCAM" resourceRoot="" soapui-version="5.2.1" xmlns:con="http://revive.com/soapui/config"><con:settings/><con:interface xsi:type="con:WsdlInterface" id="3hg43hj4g3hg" wsaVersion="NONE" name="DDUpiCAM_Binding" type="wsdl" bindingName="{http://osb.shp.com/DDUpiCAM}DDUpiCAM_Binding" soapVersion="1_1" anonymous="optional" definition="https://wsi-ppt2.shp.com/dv/DDUpiCAM/ProxyService/DDUpiCAMPS?wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:settings/><con:definitionCache type="TEXT" rootPart="https://wsi-ppt2.shp.com/dv/DDUpiCAM/ProxyService/DDUpiCAMPS?wsdl"><con:part><con:url>https://wsi-ppt2.shp.com/dv/DDUpiCAM/ProxyService/DDUpiCAMPS?wsdl</con:url><con:content><![CDATA[<WL5G3N0:definitions targetNamespace="http://osb.shp.com/DDUpiCAM" xmlns:WL5G3N0="http://schemas.xmlsoap.org/wsdl/" xmlns:WL5G3N1="http://osb.shp.com/xsd/Header" xmlns:WL5G3N2="http://osb.shp.com/xsd/DDUpiCAM" xmlns:WL5G3N3="http://osb.shp.com/DDUpiCAM" xmlns:WL5G3N4="http://schemas.xmlsoap.org/wsdl/soap/">
  <WL5G3N0:documentation>Service to access DDUpiCAM</WL5G3N0:documentation>
  <WL5G3N0:types>
    <xs:schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:hdr="http://osb.shp.com/xsd/Header" xmlns:ns0="http://osb.shp.com/xsd/DDUpiCAM" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://osb.shp.com/DDUpiCAM" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:import namespace="http://osb.shp.com/xsd/Header" schemaLocation="http:///DDUpiCAM/ProxyService/DDUpiCAMPS?SCHEMA%2FCommonInterfaces%2Fxsd%2FLocalHeader"/>
      <xs:import namespace="http://osb.shp.com/xsd/DDUpiCAM" schemaLocation="http:///DDUpiCAM/ProxyService/DDUpiCAMPS?SCHEMA%2FDDUpiCAM%2FResources%2Fxsd%2Fds%2FprocessUPIUC"/>
    </xs:schema>
  </WL5G3N0:types>
  <WL5G3N0:message name="processUPIUCRequestMessage">
    <WL5G3N0:part element="WL5G3N1:RequestHeader" name="RequestHeaderInformation"/>
    <WL5G3N0:part element="WL5G3N2:ProcessUpiRequest" name="processUPIUCRequest"/>
  </WL5G3N0:message>
  <WL5G3N0:message name="processUPIUCResponseMessage">
    <WL5G3N0:part element="WL5G3N2:ProcessUpiResponse" name="processUPIUCResponse"/>
  </WL5G3N0:message>
  <WL5G3N0:portType name="DDUpiCAMPT">
    <WL5G3N0:operation name="processUPI">
      <WL5G3N0:input message="WL5G3N3:processUPIUCRequestMessage"/>
      <WL5G3N0:output message="WL5G3N3:processUPIUCResponseMessage"/>
    </WL5G3N0:operation>
  </WL5G3N0:portType>
  <WL5G3N0:binding name="DDUpiCAM_Binding" type="WL5G3N3:DDUpiCAMPT">
    <WL5G3N4:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <WL5G3N0:operation name="processUPI">
      <WL5G3N4:operation soapAction="urn:processUPI" style="document"/>
      <WL5G3N0:input>
        <WL5G3N4:header message="WL5G3N3:processUPIUCRequestMessage" part="RequestHeaderInformation" use="literal"/>
        <WL5G3N4:body parts="processUPIUCRequest" use="literal"/>
      </WL5G3N0:input>
      <WL5G3N0:output>
        <WL5G3N4:body use="literal"/>
      </WL5G3N0:output>
    </WL5G3N0:operation>
  </WL5G3N0:binding>
  <WL5G3N0:service name="DDUpiCAM">
    <WL5G3N0:port binding="WL5G3N3:DDUpiCAM_Binding" name="DDUpiCAM_port_http">
      <WL5G3N4:address location="http:///DDUpiCAM/ProxyService/DDUpiCAMPS"/>
    </WL5G3N0:port>
  </WL5G3N0:service>
</WL5G3N0:definitions>]]></con:content><con:type>http://schemas.xmlsoap.org/wsdl/</con:type></con:part><con:part><con:url>http:///DDUpiCAM/ProxyService/DDUpiCAMPS?SCHEMA%2FCommonInterfaces%2Fxsd%2FLocalHeader</con:url><con:content><![CDATA[<!--========================================================================
//========================================================================-->
<xs:schema elementFormDefault="qualified" attributeFormDefault="qualified" targetNamespace="http://osb.shp.com/xsd/Header" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://osb.shp.com/xsd/Header">
  <!--RequestHeader Type required for SDG internal auditing-->
  <xs:element name="RequestHeader" type="tns:RequestHeaderType"/>
  <xs:complexType name="RequestHeaderType">
    <xs:sequence>
      <xs:element name="CallingApplicationName" type="xs:string" minOccurs="0"/>
      <xs:element name="TransactionId" type="xs:string" minOccurs="0"/>
      <xs:element name="Version" type="xs:string" minOccurs="0"/>
      <xs:element name="AuditLevel" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>]]></con:content><con:type>http://www.w3.org/2001/XMLSchema</con:type></con:part><con:part><con:url>http:///DDUpiCAM/ProxyService/DDUpiCAMPS?SCHEMA%2FDDUpiCAM%2FResources%2Fxsd%2Fds%2FprocessUPIUC</con:url><con:content><![CDATA[<!--//======================================================================== 

//========================================================================-->
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://osb.shp.com/xsd/DDUpiCAM" xmlns:tns="http://osb.shp.com/xsd/DDUpiCAM" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexType name="processUPIUCRequestType">
    <xs:sequence>
      <xs:element name="CaContractNumber" type="xs:string" minOccurs="0" nillable="true"/>
      <xs:element name="CaOrderNumber" type="xs:integer" minOccurs="0" nillable="true"/>
      <xs:element name="CaDDOrderNumber" type="xs:string" minOccurs="0" nillable="true"/>
      <xs:element name="CaUpiNumber" type="xs:string" minOccurs="0" nillable="true"/>
      <xs:element name="CaMasterProductInd" type="xs:integer" minOccurs="0" nillable="true"/>
      <xs:element name="CaOrderItemComponentNo" type="xs:integer" minOccurs="0" nillable="true"/>
      <xs:element name="RaReturnInd" type="xs:integer" minOccurs="0" nillable="true"/>
      <xs:element name="RaReturnMsg" type="xs:string" minOccurs="0" nillable="true"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="processUPIUCResponseType">
    <xs:sequence>
      <xs:element name="RaReturnInd" type="xs:integer"/>
      <xs:element name="RaReturnMsg" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
  <xs:element name="ProcessUpiRequest" type="tns:processUPIUCRequestType"/>
  <xs:element name="ProcessUpiResponse" type="tns:processUPIUCResponseType"/>
</xs:schema>]]></con:content><con:type>http://www.w3.org/2001/XMLSchema</con:type></con:part></con:definitionCache><con:endpoints><con:endpoint>http:///DDUpiCAM/ProxyService/DDUpiCAMPS</con:endpoint></con:endpoints><con:operation id="7d687d6fd876f86d" isOneWay="false" action="urn:processUPI" name="processUPI" bindingOperationName="processUPI" type="Request-Response" inputName="" receivesAttachments="false" sendsAttachments="false" anonymous="optional"><con:settings/><con:call id="76d76d87d6f87d6f" name="Success_01"><con:settings><con:setting id="com.revivie.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:encoding>UTF-8</con:encoding><con:endpoint>http://DDUpiCAM/ProxyService/DDUpiCAMPS</con:endpoint><con:request><![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:head="http://osb.shp.com/xsd/Header" xmlns:ddup="http://osb.shp.com/xsd/DDUpiCAM">\r
   <soapenv:Body>\r
      <ddup:ProcessUpiRequest>\r
         <!--Optional:-->\r
         <ddup:CaContractNumber>10</ddup:CaContractNumber>\r
         <!--Optional:-->\r
         <ddup:CaOrderNumber>10</ddup:CaOrderNumber>\r
         <!--Optional:-->\r
         <ddup:CaDDOrderNumber>10</ddup:CaDDOrderNumber>\r
         <!--Optional:-->\r
         <ddup:CaUpiNumber>10</ddup:CaUpiNumber>\r
         <!--Optional:-->\r
         <ddup:CaMasterProductInd>10</ddup:CaMasterProductInd>\r
         <!--Optional:-->\r
         <ddup:CaOrderItemComponentNo>10</ddup:CaOrderItemComponentNo>\r
           </ddup:ProcessUpiRequest>\r
   </soapenv:Body>\r
</soapenv:Envelope>]]></con:request><con:credentials><con:authType>No Authorization</con:authType></con:credentials><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:wsaConfig mustUnderstand="NONE" version="200508" action="urn:processUPI"/><con:wsrmConfig version="1.2"/></con:call></con:operation></con:interface><con:properties/><con:wssContainer/><con:oAuth2ProfileContainer/></con:soapui-project>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题