2016-08-12 1 views
0

Ich bekomme eine Vielzahl von wilden und wunderbare Fehler von "400 schlechte Anfrage" bis "falsche Benutzername/Passwort" und "kein Benutzername" und "kein Passwort oder Callback-Handler verfügbar ", wenn versucht wird, einen code-generierten Java-Client mit einem .NET-Soap-Dienst zu verbinden, für den WS-Security aktiviert ist.Problem beim Verbinden von Java-Soap-Client mit Ws-Sicherheit .NET Webservice

Das Folgende ist die WSDL für die .NET-Service:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://filesubmissionservice.fset.rsi" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="FileSubmissionService" targetNamespace="http://filesubmissionservice.fset.rsi"> 
<wsp:Policy wsu:Id="BasicHttpsBinding_IFileSubmissionService_policy"> 
<wsp:ExactlyOne> 
<wsp:All> 
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
<wsp:Policy> 
<sp:TransportToken> 
<wsp:Policy> 
<sp:HttpsToken RequireClientCertificate="false"/> 
</wsp:Policy> 
</sp:TransportToken> 
<sp:AlgorithmSuite> 
<wsp:Policy> 
<sp:Basic256/> 
</wsp:Policy> 
</sp:AlgorithmSuite> 
<sp:Layout> 
<wsp:Policy> 
<sp:Lax/> 
</wsp:Policy> 
</sp:Layout> 
<sp:IncludeTimestamp/> 
</wsp:Policy> 
</sp:TransportBinding> 
<sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
<wsp:Policy> 
<sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"> 
<wsp:Policy> 
<sp:WssUsernameToken10/> 
</wsp:Policy> 
</sp:UsernameToken> 
</wsp:Policy> 
</sp:SignedSupportingTokens> 
<sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
<wsp:Policy/> 
</sp:Wss10> 
</wsp:All> 
</wsp:ExactlyOne> 
</wsp:Policy> 
<wsdl:types> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://filesubmissionservice.fset.rsi"> 
<xs:import namespace="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Service.FileSubmissionService"/> 
<xs:import namespace="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Core"/> 
<xs:element name="ValidateFlatFile"> 
<xs:complexType> 
<xs:sequence> 
<xs:element minOccurs="0" name="fileName" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="file" nillable="true" type="xs:base64Binary"/> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
<xs:element name="ValidateFlatFileResponse"> 
<xs:complexType> 
<xs:sequence> 
<xs:element xmlns:q1="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Service.FileSubmissionService" minOccurs="0" name="ValidateFlatFileResult" nillable="true" type="q1:SubmissionValidationResults"/> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
<xs:element name="ValidateXmlFile"> 
<xs:complexType> 
<xs:sequence> 
<xs:element minOccurs="0" name="xmlContents" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="submissionType" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="schemaVersion" nillable="true" type="xs:string"/> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
<xs:element name="ValidateXmlFileResponse"> 
<xs:complexType> 
<xs:sequence> 
<xs:element xmlns:q2="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Service.FileSubmissionService" minOccurs="0" name="ValidateXmlFileResult" nillable="true" type="q2:SubmissionValidationResults"/> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
<xs:element name="SubmitMessage"> 
<xs:complexType> 
<xs:sequence> 
<xs:element xmlns:q3="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Core" minOccurs="0" name="message" nillable="true" type="q3:MessageData"/> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
<xs:element name="SubmitMessageResponse"> 
<xs:complexType> 
<xs:sequence> 
<xs:element minOccurs="0" name="SubmitMessageResult" nillable="true" type="xs:string"/> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
</xs:schema> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/"> 
<xs:element name="anyType" nillable="true" type="xs:anyType"/> 
<xs:element name="anyURI" nillable="true" type="xs:anyURI"/> 
<xs:element name="base64Binary" nillable="true" type="xs:base64Binary"/> 
<xs:element name="boolean" nillable="true" type="xs:boolean"/> 
<xs:element name="byte" nillable="true" type="xs:byte"/> 
<xs:element name="dateTime" nillable="true" type="xs:dateTime"/> 
<xs:element name="decimal" nillable="true" type="xs:decimal"/> 
<xs:element name="double" nillable="true" type="xs:double"/> 
<xs:element name="float" nillable="true" type="xs:float"/> 
<xs:element name="int" nillable="true" type="xs:int"/> 
<xs:element name="long" nillable="true" type="xs:long"/> 
<xs:element name="QName" nillable="true" type="xs:QName"/> 
<xs:element name="short" nillable="true" type="xs:short"/> 
<xs:element name="string" nillable="true" type="xs:string"/> 
<xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte"/> 
<xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt"/> 
<xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong"/> 
<xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort"/> 
<xs:element name="char" nillable="true" type="tns:char"/> 
<xs:simpleType name="char"> 
<xs:restriction base="xs:int"/> 
</xs:simpleType> 
<xs:element name="duration" nillable="true" type="tns:duration"/> 
<xs:simpleType name="duration"> 
<xs:restriction base="xs:duration"> 
<xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/> 
<xs:minInclusive value="-P10675199DT2H48M5.4775808S"/> 
<xs:maxInclusive value="P10675199DT2H48M5.4775807S"/> 
</xs:restriction> 
</xs:simpleType> 
<xs:element name="guid" nillable="true" type="tns:guid"/> 
<xs:simpleType name="guid"> 
<xs:restriction base="xs:string"> 
<xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/> 
</xs:restriction> 
</xs:simpleType> 
<xs:attribute name="FactoryType" type="xs:QName"/> 
<xs:attribute name="Id" type="xs:ID"/> 
<xs:attribute name="Ref" type="xs:IDREF"/> 
</xs:schema> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Service.FileSubmissionService" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Service.FileSubmissionService"> 
<xs:import namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/> 
<xs:import namespace="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Core"/> 
<xs:complexType name="SubmissionValidationResults"> 
<xs:sequence> 
<xs:element xmlns:q1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" minOccurs="0" name="ResultVars" nillable="true" type="q1:ArrayOfKeyValueOfstringstring"/> 
<xs:element xmlns:q2="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Core" minOccurs="0" name="Submissions" nillable="true" type="q2:ArrayOfSubmissionFormData"/> 
<xs:element xmlns:q3="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Core" minOccurs="0" name="ValidationErrors" nillable="true" type="q3:ArrayOfErrorInfo"/> 
</xs:sequence> 
</xs:complexType> 
<xs:element name="SubmissionValidationResults" nillable="true" type="tns:SubmissionValidationResults"/> 
</xs:schema> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> 
<xs:complexType name="ArrayOfKeyValueOfstringstring"> 
<xs:annotation> 
<xs:appinfo> 
<IsDictionary xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</IsDictionary> 
</xs:appinfo> 
</xs:annotation> 
<xs:sequence> 
<xs:element minOccurs="0" maxOccurs="unbounded" name="KeyValueOfstringstring"> 
<xs:complexType> 
<xs:sequence> 
<xs:element name="Key" nillable="true" type="xs:string"/> 
<xs:element name="Value" nillable="true" type="xs:string"/> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
</xs:sequence> 
</xs:complexType> 
<xs:element name="ArrayOfKeyValueOfstringstring" nillable="true" type="tns:ArrayOfKeyValueOfstringstring"/> 
<xs:complexType name="ArrayOfKeyValueOfstringanyType"> 
<xs:annotation> 
<xs:appinfo> 
<IsDictionary xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</IsDictionary> 
</xs:appinfo> 
</xs:annotation> 
<xs:sequence> 
<xs:element minOccurs="0" maxOccurs="unbounded" name="KeyValueOfstringanyType"> 
<xs:complexType> 
<xs:sequence> 
<xs:element name="Key" nillable="true" type="xs:string"/> 
<xs:element name="Value" nillable="true" type="xs:anyType"/> 
</xs:sequence> 
</xs:complexType> 
</xs:element> 
</xs:sequence> 
</xs:complexType> 
<xs:element name="ArrayOfKeyValueOfstringanyType" nillable="true" type="tns:ArrayOfKeyValueOfstringanyType"/> 
</xs:schema> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Core" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Core"> 
<xs:import namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/> 
<xs:import namespace="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Plugin"/> 
<xs:complexType name="ArrayOfSubmissionFormData"> 
<xs:sequence> 
<xs:element minOccurs="0" maxOccurs="unbounded" name="SubmissionFormData" nillable="true" type="tns:SubmissionFormData"/> 
</xs:sequence> 
</xs:complexType> 
<xs:element name="ArrayOfSubmissionFormData" nillable="true" type="tns:ArrayOfSubmissionFormData"/> 
<xs:complexType name="SubmissionFormData"> 
<xs:sequence> 
<xs:element minOccurs="0" name="ContainsPayment" type="xs:boolean"/> 
<xs:element minOccurs="0" name="ETIN" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="ElectronicPostmark" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="FilerName" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="FormDataStr" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="IdentityNumber" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="IdentityType" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="Jurisdiction" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="MessageId" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="MessageKey" nillable="true" type="xs:int"/> 
<xs:element minOccurs="0" name="MessageSource" nillable="true" type="xs:int"/> 
<xs:element xmlns:q1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" minOccurs="0" name="PluginVars" nillable="true" type="q1:ArrayOfKeyValueOfstringanyType"/> 
<xs:element minOccurs="0" name="ReceivedTimestamp" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="SWID" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="SchemaLocation" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="SchemaVersion" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="SoftwareId" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="Status" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="SubmissionCategory" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="SubmissionId" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="SubmissionKey" nillable="true" type="xs:int"/> 
<xs:element minOccurs="0" name="SubmissionType" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="TaxYear" type="xs:int"/> 
</xs:sequence> 
</xs:complexType> 
<xs:element name="SubmissionFormData" nillable="true" type="tns:SubmissionFormData"/> 
<xs:complexType name="ArrayOfErrorInfo"> 
<xs:sequence> 
<xs:element minOccurs="0" maxOccurs="unbounded" name="ErrorInfo" nillable="true" type="tns:ErrorInfo"/> 
</xs:sequence> 
</xs:complexType> 
<xs:element name="ArrayOfErrorInfo" nillable="true" type="tns:ArrayOfErrorInfo"/> 
<xs:complexType name="ErrorInfo"> 
<xs:sequence> 
<xs:element minOccurs="0" name="DataValue" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="DocumentId" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="ErrorCategory" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="ErrorMessage" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="RuleNumber" nillable="true" type="xs:string"/> 
<xs:element xmlns:q2="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Plugin" minOccurs="0" name="Severity" type="q2:RuleSeverity"/> 
<xs:element minOccurs="0" name="XPath" nillable="true" type="xs:string"/> 
</xs:sequence> 
</xs:complexType> 
<xs:element name="ErrorInfo" nillable="true" type="tns:ErrorInfo"/> 
<xs:complexType name="MessageData"> 
<xs:sequence> 
<xs:element minOccurs="0" name="MessageID" nillable="true" type="xs:string"/> 
<xs:element minOccurs="0" name="MessageKey" nillable="true" type="xs:int"/> 
<xs:element minOccurs="0" name="Source" type="xs:int"/> 
<xs:element minOccurs="0" name="Submissions" nillable="true" type="tns:ArrayOfSubmissionFormData"/> 
</xs:sequence> 
</xs:complexType> 
<xs:element name="MessageData" nillable="true" type="tns:MessageData"/> 
</xs:schema> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Plugin" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Plugin"> 
<xs:simpleType name="RuleSeverity"> 
<xs:restriction base="xs:string"> 
<xs:enumeration value="RejectAndStop"/> 
<xs:enumeration value="Reject"/> 
<xs:enumeration value="Alert"/> 
</xs:restriction> 
</xs:simpleType> 
<xs:element name="RuleSeverity" nillable="true" type="tns:RuleSeverity"/> 
</xs:schema> 
</wsdl:types> 
<wsdl:message name="IFileSubmissionService_ValidateFlatFile_InputMessage"> 
<wsdl:part name="parameters" element="tns:ValidateFlatFile"/> 
</wsdl:message> 
<wsdl:message name="IFileSubmissionService_ValidateFlatFile_OutputMessage"> 
<wsdl:part name="parameters" element="tns:ValidateFlatFileResponse"/> 
</wsdl:message> 
<wsdl:message name="IFileSubmissionService_ValidateXmlFile_InputMessage"> 
<wsdl:part name="parameters" element="tns:ValidateXmlFile"/> 
</wsdl:message> 
<wsdl:message name="IFileSubmissionService_ValidateXmlFile_OutputMessage"> 
<wsdl:part name="parameters" element="tns:ValidateXmlFileResponse"/> 
</wsdl:message> 
<wsdl:message name="IFileSubmissionService_SubmitMessage_InputMessage"> 
<wsdl:part name="parameters" element="tns:SubmitMessage"/> 
</wsdl:message> 
<wsdl:message name="IFileSubmissionService_SubmitMessage_OutputMessage"> 
<wsdl:part name="parameters" element="tns:SubmitMessageResponse"/> 
</wsdl:message> 
<wsdl:portType name="IFileSubmissionService"> 
<wsdl:operation name="ValidateFlatFile"> 
<wsdl:input wsaw:Action="http://filesubmissionservice.fset.rsi/IFileSubmissionService/ValidateFlatFile" message="tns:IFileSubmissionService_ValidateFlatFile_InputMessage"/> 
<wsdl:output wsaw:Action="http://filesubmissionservice.fset.rsi/IFileSubmissionService/ValidateFlatFileResponse" message="tns:IFileSubmissionService_ValidateFlatFile_OutputMessage"/> 
</wsdl:operation> 
<wsdl:operation name="ValidateXmlFile"> 
<wsdl:input wsaw:Action="http://filesubmissionservice.fset.rsi/IFileSubmissionService/ValidateXmlFile" message="tns:IFileSubmissionService_ValidateXmlFile_InputMessage"/> 
<wsdl:output wsaw:Action="http://filesubmissionservice.fset.rsi/IFileSubmissionService/ValidateXmlFileResponse" message="tns:IFileSubmissionService_ValidateXmlFile_OutputMessage"/> 
</wsdl:operation> 
<wsdl:operation name="SubmitMessage"> 
<wsdl:input wsaw:Action="http://filesubmissionservice.fset.rsi/IFileSubmissionService/SubmitMessage" message="tns:IFileSubmissionService_SubmitMessage_InputMessage"/> 
<wsdl:output wsaw:Action="http://filesubmissionservice.fset.rsi/IFileSubmissionService/SubmitMessageResponse" message="tns:IFileSubmissionService_SubmitMessage_OutputMessage"/> 
</wsdl:operation> 
</wsdl:portType> 
<wsdl:binding name="BasicHttpsBinding_IFileSubmissionService" type="tns:IFileSubmissionService"> 
<wsp:PolicyReference URI="#BasicHttpsBinding_IFileSubmissionService_policy"/> 
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> 
<wsdl:operation name="ValidateFlatFile"> 
<soap:operation soapAction="http://filesubmissionservice.fset.rsi/IFileSubmissionService/ValidateFlatFile" style="document"/> 
<wsdl:input> 
<soap:body use="literal"/> 
</wsdl:input> 
<wsdl:output> 
<soap:body use="literal"/> 
</wsdl:output> 
</wsdl:operation> 
<wsdl:operation name="ValidateXmlFile"> 
<soap:operation soapAction="http://filesubmissionservice.fset.rsi/IFileSubmissionService/ValidateXmlFile" style="document"/> 
<wsdl:input> 
<soap:body use="literal"/> 
</wsdl:input> 
<wsdl:output> 
<soap:body use="literal"/> 
</wsdl:output> 
</wsdl:operation> 
<wsdl:operation name="SubmitMessage"> 
<soap:operation soapAction="http://filesubmissionservice.fset.rsi/IFileSubmissionService/SubmitMessage" style="document"/> 
<wsdl:input> 
<soap:body use="literal"/> 
</wsdl:input> 
<wsdl:output> 
<soap:body use="literal"/> 
</wsdl:output> 
</wsdl:operation> 
</wsdl:binding> 
<wsdl:service name="FileSubmissionService"> 
<wsdl:port name="BasicHttpsBinding_IFileSubmissionService" binding="tns:BasicHttpsBinding_IFileSubmissionService"> 
<soap:address location="https://10.1.2.166/FileSubmissionService/FileSubmissionService.svc"/> 
</wsdl:port> 
</wsdl:service> 
</wsdl:definitions> 

und folgendes, wo ich den Code generiert Java-Client aufrufen und das Hinzufügen der Header:

private IFileSubmissionService createFileSubmissionServiceClient() { 

    final String webserviceURL = applicationSessionBean.getExtProperties().getProperty("fileSubmissionServiceURL"); 
    final String username = applicationSessionBean.getExtProperties().getProperty("wsuser"); 
    final String password = applicationSessionBean.getExtProperties().getProperty("wspass"); 

    FileSubmissionService fsService = null; 

    try { 
     fsService = new FileSubmissionService(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

    if(fsService == null) { 
     //get service with default WSDL location 
     fsService = new FileSubmissionService(); 
    } 

    IFileSubmissionService client = fsService.getBasicHttpsBindingIFileSubmissionService(); 

    String  salt   = "XXXXXXXX"; 


    // Add security header 
    Map<String, Object> ctx = ((BindingProvider)client).getRequestContext(); 
    ctx.put("ws-security.username", username); 
    ctx.put("ws-security.password", getSecurePassword(password, salt.getBytes())); 
    ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, webserviceURL); 

    // Add headers 
    List<Handler> handlerChain = new ArrayList<Handler>(); 
    handlerChain.add(new HeaderHandler(username, getSecurePassword(password, salt.getBytes()))); 
    ((BindingProvider)client).getBinding().setHandlerChain(handlerChain); 

    return client; 
} 

Und die Folgendes ist mein "Header-Handler", wo ich die Sicherheits-Header angehängt habe:

Und f ndlich ist hier eine Probe der SOAP-Nachricht erzeugt:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
    <S:Header xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> 
     <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" S:mustUnderstand="1"> 
      <wsu:Timestamp wsu:Id="_0"> 
       <wsu:Created>2016-08-12T20:37:42.282Z</wsu:Created> 
       <wsu:Expires>2016-08-12T20:38:42.282Z</wsu:Expires> 
      </wsu:Timestamp> 
      <wsse:UsernameToken wsu:Id="uuid-a5eb8c04-b9d0-4035-acd5-50fae8254d4a"> 
       <wsse:Username>XXXXXXXX</wsse:Username> 
       <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XXXXXXXX</wsse:Password> 
      </wsse:UsernameToken> 
     </wsse:Security> 
    </S:Header> 
    <soap:Body> 
     <ValidateXmlFile xmlns="http://filesubmissionservice.fset.rsi" xmlns:ns2="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:ns3="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Service.FileSubmissionService" xmlns:ns4="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Core" xmlns:ns5="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns6="http://schemas.datacontract.org/2004/07/RSI.StateGateway.Plugin"> 
      <xmlContents>A</xmlContents> 
      <submissionType>NC3</submissionType> 
      <schemaVersion>FSETStateAnnualFilingV5.2</schemaVersion> 
     </ValidateXmlFile> 
    </soap:Body> 
</soap:Envelope> 

Das Problem ist, ich die folgende Fehlermeldung erhalte:

org.apache.cxf.transport.http.HTTPException: HTTP response '400: Bad Request' when communicating with https://10.1.2.166/FileSubmissionService/FileSubmissionService.svc 

ich auch die oben genannten Meldungen immer bin, wenn ich versuche zu spielen um mit dem Entfernen die Kopfzeileninjektion und/oder nicht Setzen oder Einstellen der Benutzer-/Passwortvariablen des Anforderungskontextes.

Was ich nicht verstehe ist A) Warum bekomme ich einen Fehler im Zusammenhang mit Apache CXF, wenn ich Apache CXF nicht verwende und B) warum ist es eine schlechte Anfrage?

Kann mir jemand in die richtige Richtung zeigen? Ich möchte einfach Vanille Java verwenden, um den Client zu erstellen. Ich bin mir nicht sicher, ob ich dafür Toolkits von Drittanbietern benötige.

Vielen Dank!

+0

Ich würde eine Prämie dafür starten, wie ich wirklich eine Antwort brauche, aber ich kann das nicht tun, bis mein Ruf 75 ist? Ich bin verwirrt über die Unterschiede in der Umsetzung zwischen reinen Java-Soap-Services und der Achse, Achse 2, CXF, Feder und andere Implementierungen. Ich habe die WS-Sicherheitsspezifikation befolgt und wie Sie sehen können, habe ich die richtigen Header hinzugefügt und stelle die erwartete Ausgabe bereit. Warum ich eine "schlechte Anfrage" bekomme, kann ich nicht beantworten. – Matt1776

Antwort

0

Okay, hier ist der Grund. Das Abfangen der Nachricht und das manuelle Setzen der Header und das Setzen des Benutzernamens und des Passworts im Anfragekontext sind zwei völlig unterschiedliche Ansätze in JAX-WS, die dasselbe erreichen.

Der folgende Beitrag erläutert den Unterschied zwischen den beiden: Difference between RequestContext and MessageContext in JAX WS

Was ich tat, beide Verfahren wurde unter Verwendung, die in einer Anfrage zur Folge, dass die webservice mal geformt und verursacht war eine HTTP kotzen und zurück 400 Code.

Der Grund, dass dies nicht abgefangen wurde, ist, dass ich die SOAP-Nachricht in der Handler-Kette (die manuelle Methode) protokollierte, aber die letzte ausgehende Nachricht nicht druckte, nachdem der Anfragekontext geändert wurde.

Wenn jemand weiter auf diese zwei verschiedenen Ansätze näher eingehen kann, wäre ich für immer dankbar. Ich verstehe immer noch nicht den Unterschied hier und ich könnte falsch in meinen Schlussfolgerungen sein

Verwandte Themen