Repository: reficio/soap-ws Branch: master Commit: 93e5a7956ed6 Files: 549 Total size: 1.9 MB Directory structure: gitextract_cqglr56k/ ├── .gitignore ├── .travis.yml ├── README.md ├── pom.xml ├── soap-builder/ │ ├── pom.xml │ └── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── reficio/ │ │ │ └── ws/ │ │ │ └── builder/ │ │ │ ├── SoapBuilder.java │ │ │ ├── SoapBuilderFinder.java │ │ │ ├── SoapOperation.java │ │ │ ├── SoapOperationBuilder.java │ │ │ ├── SoapOperationFinder.java │ │ │ └── core/ │ │ │ ├── SoapBuilderImpl.java │ │ │ ├── SoapOperationFinderImpl.java │ │ │ ├── SoapOperationImpl.java │ │ │ ├── SoapUtils.java │ │ │ └── Wsdl.java │ │ └── resources/ │ │ └── xsds/ │ │ ├── XMLSchema.xsd │ │ ├── soapEncoding.xsd │ │ ├── soapEncoding12.xsd │ │ ├── soapEnvelope.xsd │ │ ├── soapEnvelope12.xsd │ │ ├── swaref.xsd │ │ ├── xmime200411.xsd │ │ ├── xmime200505.xsd │ │ ├── xml.xsd │ │ └── xop.xsd │ └── test/ │ ├── java/ │ │ └── org/ │ │ └── reficio/ │ │ └── ws/ │ │ └── builder/ │ │ ├── DefinitionSaveTest.java │ │ ├── MessageComplianceTest.java │ │ ├── ServiceComplianceTest.java │ │ ├── SoapBuilderImplTest.java │ │ ├── SoapOperationFinderImplTest.java │ │ └── WsdlTest.java │ └── resources/ │ ├── builder/ │ │ └── snowboard.wsdl │ ├── log4j.xml │ ├── messages/ │ │ ├── EmptyFault11.xml │ │ ├── EmptyFault12.xml │ │ ├── EmptyMessage11.xml │ │ ├── EmptyMessage12.xml │ │ ├── FaultVersionMismatch11.xml │ │ └── FaultVersionMismatch12.xml │ ├── services/ │ │ ├── test01/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── TestServiceSoap/ │ │ │ │ │ ├── Copy.request.xml │ │ │ │ │ ├── Copy.response.xml │ │ │ │ │ ├── Delete.request.xml │ │ │ │ │ ├── Delete.response.xml │ │ │ │ │ ├── DeleteChildren.request.xml │ │ │ │ │ ├── DeleteChildren.response.xml │ │ │ │ │ ├── DeleteVersion.request.xml │ │ │ │ │ ├── DeleteVersion.response.xml │ │ │ │ │ ├── FindPagesWithCriteria.request.xml │ │ │ │ │ ├── FindPagesWithCriteria.response.xml │ │ │ │ │ ├── GetChildren.request.xml │ │ │ │ │ ├── GetChildren.response.xml │ │ │ │ │ ├── GetDefaultPageData.request.xml │ │ │ │ │ ├── GetDefaultPageData.response.xml │ │ │ │ │ ├── GetPage.request.xml │ │ │ │ │ ├── GetPage.response.xml │ │ │ │ │ ├── Move.request.xml │ │ │ │ │ ├── Move.response.xml │ │ │ │ │ ├── Ping.request.xml │ │ │ │ │ ├── Ping.response.xml │ │ │ │ │ ├── Save.request.xml │ │ │ │ │ └── Save.response.xml │ │ │ │ └── soap-version.txt │ │ │ ├── readme.txt │ │ │ ├── testservice1.xsd │ │ │ └── testservice2.xsd │ │ ├── test02/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── TestServiceSoap/ │ │ │ │ │ ├── Copy.request.xml │ │ │ │ │ ├── Copy.response.xml │ │ │ │ │ ├── Delete.request.xml │ │ │ │ │ ├── Delete.response.xml │ │ │ │ │ ├── DeleteChildren.request.xml │ │ │ │ │ ├── DeleteChildren.response.xml │ │ │ │ │ ├── DeleteVersion.request.xml │ │ │ │ │ ├── DeleteVersion.response.xml │ │ │ │ │ ├── FindPagesWithCriteria.request.xml │ │ │ │ │ ├── FindPagesWithCriteria.response.xml │ │ │ │ │ ├── GetChildren.request.xml │ │ │ │ │ ├── GetChildren.response.xml │ │ │ │ │ ├── GetDefaultPageData.request.xml │ │ │ │ │ ├── GetDefaultPageData.response.xml │ │ │ │ │ ├── GetPage.request.xml │ │ │ │ │ ├── GetPage.response.xml │ │ │ │ │ ├── Move.request.xml │ │ │ │ │ ├── Move.response.xml │ │ │ │ │ ├── Ping.request.xml │ │ │ │ │ ├── Ping.response.xml │ │ │ │ │ ├── Save.request.xml │ │ │ │ │ └── Save.response.xml │ │ │ │ └── soap-version.txt │ │ │ ├── readme.txt │ │ │ ├── testservice1.xsd │ │ │ └── testservice2.xsd │ │ ├── test03/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── TestServiceSoap/ │ │ │ │ │ ├── Copy.request.xml │ │ │ │ │ ├── Copy.response.xml │ │ │ │ │ ├── Delete.request.xml │ │ │ │ │ ├── Delete.response.xml │ │ │ │ │ ├── DeleteChildren.request.xml │ │ │ │ │ ├── DeleteChildren.response.xml │ │ │ │ │ ├── DeleteVersion.request.xml │ │ │ │ │ ├── DeleteVersion.response.xml │ │ │ │ │ ├── FindPagesWithCriteria.request.xml │ │ │ │ │ ├── FindPagesWithCriteria.response.xml │ │ │ │ │ ├── GetChildren.request.xml │ │ │ │ │ ├── GetChildren.response.xml │ │ │ │ │ ├── GetDefaultPageData.request.xml │ │ │ │ │ ├── GetDefaultPageData.response.xml │ │ │ │ │ ├── GetPage.request.xml │ │ │ │ │ ├── GetPage.response.xml │ │ │ │ │ ├── Move.request.xml │ │ │ │ │ ├── Move.response.xml │ │ │ │ │ ├── Ping.request.xml │ │ │ │ │ ├── Ping.response.xml │ │ │ │ │ ├── Save.request.xml │ │ │ │ │ └── Save.response.xml │ │ │ │ └── soap-version.txt │ │ │ ├── readme.txt │ │ │ ├── testservice1.xsd │ │ │ └── testservice2.xsd │ │ ├── test04/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── TestServiceSoap/ │ │ │ │ │ ├── Copy.request.xml │ │ │ │ │ ├── Copy.response.xml │ │ │ │ │ ├── Delete.request.xml │ │ │ │ │ ├── Delete.response.xml │ │ │ │ │ ├── DeleteChildren.request.xml │ │ │ │ │ ├── DeleteChildren.response.xml │ │ │ │ │ ├── DeleteVersion.request.xml │ │ │ │ │ ├── DeleteVersion.response.xml │ │ │ │ │ ├── FindPagesWithCriteria.request.xml │ │ │ │ │ ├── FindPagesWithCriteria.response.xml │ │ │ │ │ ├── GetChildren.request.xml │ │ │ │ │ ├── GetChildren.response.xml │ │ │ │ │ ├── GetDefaultPageData.request.xml │ │ │ │ │ ├── GetDefaultPageData.response.xml │ │ │ │ │ ├── GetPage.request.xml │ │ │ │ │ ├── GetPage.response.xml │ │ │ │ │ ├── Move.request.xml │ │ │ │ │ ├── Move.response.xml │ │ │ │ │ ├── Ping.request.xml │ │ │ │ │ ├── Ping.response.xml │ │ │ │ │ ├── Save.request.xml │ │ │ │ │ └── Save.response.xml │ │ │ │ └── soap-version.txt │ │ │ ├── readme.txt │ │ │ ├── testservice1.xsd │ │ │ └── testservice2.xsd │ │ ├── test05/ │ │ │ ├── TestBinding.wsdl │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── TestServiceSoap/ │ │ │ │ │ ├── Copy.request.xml │ │ │ │ │ ├── Copy.response.xml │ │ │ │ │ ├── Delete.request.xml │ │ │ │ │ ├── Delete.response.xml │ │ │ │ │ ├── DeleteChildren.request.xml │ │ │ │ │ ├── DeleteChildren.response.xml │ │ │ │ │ ├── DeleteVersion.request.xml │ │ │ │ │ ├── DeleteVersion.response.xml │ │ │ │ │ ├── FindPagesWithCriteria.request.xml │ │ │ │ │ ├── FindPagesWithCriteria.response.xml │ │ │ │ │ ├── GetChildren.request.xml │ │ │ │ │ ├── GetChildren.response.xml │ │ │ │ │ ├── GetDefaultPageData.request.xml │ │ │ │ │ ├── GetDefaultPageData.response.xml │ │ │ │ │ ├── GetPage.request.xml │ │ │ │ │ ├── GetPage.response.xml │ │ │ │ │ ├── Move.request.xml │ │ │ │ │ ├── Move.response.xml │ │ │ │ │ ├── Ping.request.xml │ │ │ │ │ ├── Ping.response.xml │ │ │ │ │ ├── Save.request.xml │ │ │ │ │ └── Save.response.xml │ │ │ │ └── soap-version.txt │ │ │ ├── readme.txt │ │ │ ├── testservice1.xsd │ │ │ └── testservice2.xsd │ │ ├── test06/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── TestServiceSoap/ │ │ │ │ │ ├── Copy.request.xml │ │ │ │ │ ├── Copy.response.xml │ │ │ │ │ ├── Delete.request.xml │ │ │ │ │ ├── Delete.response.xml │ │ │ │ │ ├── DeleteChildren.request.xml │ │ │ │ │ ├── DeleteChildren.response.xml │ │ │ │ │ ├── DeleteVersion.request.xml │ │ │ │ │ ├── DeleteVersion.response.xml │ │ │ │ │ ├── FindPagesWithCriteria.request.xml │ │ │ │ │ ├── FindPagesWithCriteria.response.xml │ │ │ │ │ ├── GetChildren.request.xml │ │ │ │ │ ├── GetChildren.response.xml │ │ │ │ │ ├── GetDefaultPageData.request.xml │ │ │ │ │ ├── GetDefaultPageData.response.xml │ │ │ │ │ ├── GetPage.request.xml │ │ │ │ │ ├── GetPage.response.xml │ │ │ │ │ ├── Move.request.xml │ │ │ │ │ ├── Move.response.xml │ │ │ │ │ ├── Ping.request.xml │ │ │ │ │ ├── Ping.response.xml │ │ │ │ │ ├── Save.request.xml │ │ │ │ │ └── Save.response.xml │ │ │ │ └── soap-version.txt │ │ │ ├── readme.txt │ │ │ └── wsdls/ │ │ │ ├── TestBinding.wsdl │ │ │ └── xsds/ │ │ │ ├── sub/ │ │ │ │ └── testservice2.xsd │ │ │ └── testservice1.xsd │ │ ├── test07/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── TestServiceSoap/ │ │ │ │ │ ├── Copy.request.xml │ │ │ │ │ ├── Copy.response.xml │ │ │ │ │ ├── Delete.request.xml │ │ │ │ │ ├── Delete.response.xml │ │ │ │ │ ├── DeleteChildren.request.xml │ │ │ │ │ ├── DeleteChildren.response.xml │ │ │ │ │ ├── DeleteVersion.request.xml │ │ │ │ │ ├── DeleteVersion.response.xml │ │ │ │ │ ├── FindPagesWithCriteria.request.xml │ │ │ │ │ ├── FindPagesWithCriteria.response.xml │ │ │ │ │ ├── GetChildren.request.xml │ │ │ │ │ ├── GetChildren.response.xml │ │ │ │ │ ├── GetDefaultPageData.request.xml │ │ │ │ │ ├── GetDefaultPageData.response.xml │ │ │ │ │ ├── GetPage.request.xml │ │ │ │ │ ├── GetPage.response.xml │ │ │ │ │ ├── Move.request.xml │ │ │ │ │ ├── Move.response.xml │ │ │ │ │ ├── Ping.request.xml │ │ │ │ │ ├── Ping.response.xml │ │ │ │ │ ├── Save.request.xml │ │ │ │ │ └── Save.response.xml │ │ │ │ └── soap-version.txt │ │ │ ├── readme.txt │ │ │ └── wsdls/ │ │ │ ├── TestBinding.wsdl │ │ │ └── xsds/ │ │ │ ├── sub/ │ │ │ │ └── testservice2.xsd │ │ │ └── testservice1.xsd │ │ ├── test08/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── TestServiceSoap/ │ │ │ │ │ ├── Copy.request.xml │ │ │ │ │ ├── Copy.response.xml │ │ │ │ │ ├── Delete.request.xml │ │ │ │ │ ├── Delete.response.xml │ │ │ │ │ ├── DeleteChildren.request.xml │ │ │ │ │ ├── DeleteChildren.response.xml │ │ │ │ │ ├── DeleteVersion.request.xml │ │ │ │ │ ├── DeleteVersion.response.xml │ │ │ │ │ ├── FindPagesWithCriteria.request.xml │ │ │ │ │ ├── FindPagesWithCriteria.response.xml │ │ │ │ │ ├── GetChildren.request.xml │ │ │ │ │ ├── GetChildren.response.xml │ │ │ │ │ ├── GetDefaultPageData.request.xml │ │ │ │ │ ├── GetDefaultPageData.response.xml │ │ │ │ │ ├── GetPage.request.xml │ │ │ │ │ ├── GetPage.response.xml │ │ │ │ │ ├── Move.request.xml │ │ │ │ │ ├── Move.response.xml │ │ │ │ │ ├── Ping.request.xml │ │ │ │ │ ├── Ping.response.xml │ │ │ │ │ ├── Save.request.xml │ │ │ │ │ └── Save.response.xml │ │ │ │ └── soap-version.txt │ │ │ ├── readme.txt │ │ │ └── wsdls/ │ │ │ ├── TestBinding.wsdl │ │ │ ├── testservice2.xsd │ │ │ └── xsds/ │ │ │ └── testservice1.xsd │ │ ├── test09/ │ │ │ ├── TestService.wsdl │ │ │ ├── common.xsd │ │ │ ├── one.xsd │ │ │ ├── operations/ │ │ │ │ ├── Binding/ │ │ │ │ │ ├── Operation.request.xml │ │ │ │ │ └── Operation.response.xml │ │ │ │ └── soap-version.txt │ │ │ └── two.xsd │ │ ├── test10/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── TestServiceSoap/ │ │ │ │ │ ├── GetDefaultPageData.request.xml │ │ │ │ │ ├── GetDefaultPageData.response.xml │ │ │ │ │ ├── GetPage.request.xml │ │ │ │ │ └── GetPage.response.xml │ │ │ │ └── soap-version.txt │ │ │ ├── readme.txt │ │ │ ├── testservice1.xsd │ │ │ └── testservice2.xsd │ │ ├── test11/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── ADEC_MAST_Binding/ │ │ │ │ │ ├── doGetSummary.request.xml │ │ │ │ │ └── doGetSummary.response.xml │ │ │ │ └── soap-version.txt │ │ │ └── readme.txt │ │ ├── test12/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── IncrementServicePTSOAPBinding/ │ │ │ │ │ ├── process.request.xml │ │ │ │ │ └── process.response.xml │ │ │ │ └── soap-version.txt │ │ │ └── readme.txt │ │ ├── test13/ │ │ │ ├── TestService.wsdl │ │ │ ├── chameleon.xsd │ │ │ ├── operations/ │ │ │ │ ├── LinkageServiceSOAPBinding/ │ │ │ │ │ ├── addToSocialGroup.request.xml │ │ │ │ │ ├── addToSocialGroup.response.xml │ │ │ │ │ ├── createLink.request.xml │ │ │ │ │ ├── createLink.response.xml │ │ │ │ │ ├── createSocialGroup.request.xml │ │ │ │ │ ├── createSocialGroup.response.xml │ │ │ │ │ ├── readGroups.request.xml │ │ │ │ │ └── readGroups.response.xml │ │ │ │ ├── PersonaServiceSOAPBinding/ │ │ │ │ │ ├── deletePersona.request.xml │ │ │ │ │ ├── deletePersona.response.xml │ │ │ │ │ ├── readPersona.request.xml │ │ │ │ │ ├── readPersona.response.xml │ │ │ │ │ ├── readPersonas.request.xml │ │ │ │ │ ├── readPersonas.response.xml │ │ │ │ │ ├── storePersona.request.xml │ │ │ │ │ └── storePersona.response.xml │ │ │ │ └── soap-version.txt │ │ │ └── readme.txt │ │ ├── test14/ │ │ │ ├── TestService.wsdl │ │ │ └── operations/ │ │ │ ├── MakeFriendsSoapBinding/ │ │ │ │ ├── makeFriend.request.xml │ │ │ │ └── makeFriend.response.xml │ │ │ └── soap-version.txt │ │ ├── test15/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── StockQuoteSoapBinding/ │ │ │ │ │ ├── GetLastTradePrice.request.xml │ │ │ │ │ ├── GetLastTradePrice.response.xml │ │ │ │ │ ├── GetLastTradePrice2.request.xml │ │ │ │ │ └── GetLastTradePrice2.response.xml │ │ │ │ └── soap-version.txt │ │ │ └── stockquote-schema.xsd │ │ ├── test16/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── StockQuoteSoapBinding/ │ │ │ │ │ ├── GetLastTradePrice.request.xml │ │ │ │ │ └── GetLastTradePrice.response.xml │ │ │ │ └── soap-version.txt │ │ │ └── stockquote-schema.xsd │ │ ├── test17/ │ │ │ ├── TestService.wsdl │ │ │ ├── operations/ │ │ │ │ ├── StockQuoteSoapBinding/ │ │ │ │ │ ├── GetLastTradePrice.request.xml │ │ │ │ │ ├── GetLastTradePrice.response.xml │ │ │ │ │ ├── GetLastTradePrice2.request.xml │ │ │ │ │ └── GetLastTradePrice2.response.xml │ │ │ │ └── soap-version.txt │ │ │ └── stockquote-schema.xsd │ │ └── test18/ │ │ ├── TestService.wsdl │ │ └── operations/ │ │ ├── HelloWorldSoap/ │ │ │ ├── SayHelloWorld.request.xml │ │ │ └── SayHelloWorld.response.xml │ │ ├── HelloWorldSoap12/ │ │ │ ├── SayHelloWorld.request.xml │ │ │ └── SayHelloWorld.response.xml │ │ └── soap-version.txt │ └── wsdl/ │ ├── TestService.wsdl │ ├── testservice1.xsd │ └── testservice2.xsd ├── soap-client/ │ ├── pom.xml │ └── src/ │ ├── main/ │ │ └── java/ │ │ └── org/ │ │ └── reficio/ │ │ └── ws/ │ │ └── client/ │ │ ├── SoapClientException.java │ │ ├── TransmissionException.java │ │ ├── core/ │ │ │ ├── Security.java │ │ │ ├── SecurityFactory.java │ │ │ ├── SoapClient.java │ │ │ ├── SoapClientFactory.java │ │ │ └── SoapConstants.java │ │ └── ssl/ │ │ ├── MultiX509TrustManager.java │ │ └── SSLUtils.java │ └── test/ │ ├── java/ │ │ └── org/ │ │ └── reficio/ │ │ └── ws/ │ │ └── client/ │ │ └── SimpleClientTest.java │ └── resources/ │ └── log4j.xml ├── soap-common/ │ ├── pom.xml │ └── src/ │ ├── main/ │ │ └── java/ │ │ └── org/ │ │ └── reficio/ │ │ └── ws/ │ │ ├── SoapBuilderException.java │ │ ├── SoapContext.java │ │ ├── SoapException.java │ │ ├── SoapMultiValuesProvider.java │ │ ├── SoapValidationException.java │ │ ├── annotation/ │ │ │ └── ThreadSafe.java │ │ └── common/ │ │ ├── FileWriter.java │ │ ├── ResourceUtils.java │ │ ├── SimpleValuesProvider.java │ │ ├── Wsdl11Writer.java │ │ └── XmlUtils.java │ └── test/ │ ├── java/ │ │ └── org/ │ │ └── reficio/ │ │ └── ws/ │ │ └── common/ │ │ ├── ResourceLoaderTest.java │ │ ├── ResourceUtilsTest.java │ │ └── XmlComparator.java │ └── resources/ │ ├── my folder/ │ │ └── resource.txt │ └── org/ │ └── reficio/ │ └── ws/ │ └── common/ │ └── test/ │ └── soapEncoding.xsd ├── soap-examples/ │ ├── arquillian/ │ │ ├── pom.xml │ │ └── src/ │ │ └── test/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── reficio/ │ │ │ └── ws/ │ │ │ └── arquillian/ │ │ │ ├── Greeter.java │ │ │ ├── GreeterTest.java │ │ │ └── README.txt │ │ └── resources/ │ │ ├── log4j.xml │ │ └── wsdl/ │ │ └── currency-convertor.wsdl │ ├── pom.xml │ ├── quickstart/ │ │ ├── pom.xml │ │ └── src/ │ │ └── test/ │ │ ├── groovy/ │ │ │ └── org/ │ │ │ └── reficio/ │ │ │ └── ws/ │ │ │ └── quickstart/ │ │ │ └── QuickStart.groovy │ │ ├── java/ │ │ │ └── org/ │ │ │ └── reficio/ │ │ │ └── ws/ │ │ │ └── quickstart/ │ │ │ ├── SoapClientExamplesTest.java │ │ │ ├── SoapServerExamplesTest.java │ │ │ └── SpringExampleTest.java │ │ └── resources/ │ │ ├── applicationContext.xml │ │ ├── log4j.xml │ │ └── wsdl/ │ │ ├── currency-convertor.wsdl │ │ ├── stockquote-schema.xsd │ │ └── stockquote-service.wsdl │ └── testing/ │ ├── pom.xml │ └── src/ │ └── test/ │ ├── groovy/ │ │ └── org/ │ │ └── reficio/ │ │ └── sample/ │ │ ├── BankService.groovy │ │ ├── BankServiceImpl.groovy │ │ ├── testing/ │ │ │ ├── BalanceClientPlainTest.groovy │ │ │ ├── BalanceClientSpringTest.groovy │ │ │ └── ConverterServerTest.groovy │ │ └── util/ │ │ └── ExampleUtils.groovy │ └── resources/ │ ├── applicationContext.xml │ ├── log4j.xml │ └── wsdl/ │ └── currency-convertor.wsdl ├── soap-it/ │ ├── pom.xml │ └── src/ │ └── test/ │ ├── java/ │ │ └── org/ │ │ └── reficio/ │ │ └── ws/ │ │ └── it/ │ │ ├── AbstractCooperationTest.java │ │ ├── HttpCooperationTest.java │ │ ├── HttpProxyHttpCooperationTest.java │ │ ├── HttpProxyHttpsCooperationTest.java │ │ ├── HttpsCooperationTest.java │ │ ├── HttpsProxyHttpCooperationTest.java │ │ ├── HttpsProxyHttpsCooperationTest.java │ │ └── util/ │ │ ├── ClientBuilder.java │ │ ├── SslTunnel.java │ │ └── TestUtils.java │ └── resources/ │ ├── keystores/ │ │ ├── multi-cert-keystore/ │ │ │ ├── .keystore │ │ │ └── gen.sh │ │ └── single-cert-keystore/ │ │ ├── .keystore_1 │ │ ├── .keystore_2 │ │ └── gen.sh │ ├── log4j.xml │ ├── services/ │ │ ├── test01/ │ │ │ ├── TestService.wsdl │ │ │ ├── testservice1.xsd │ │ │ └── testservice2.xsd │ │ ├── test02/ │ │ │ ├── TestService.wsdl │ │ │ ├── testservice1.xsd │ │ │ └── testservice2.xsd │ │ ├── test03/ │ │ │ ├── TestService.wsdl │ │ │ ├── testservice1.xsd │ │ │ └── testservice2.xsd │ │ ├── test04/ │ │ │ ├── TestService.wsdl │ │ │ ├── testservice1.xsd │ │ │ └── testservice2.xsd │ │ ├── test05/ │ │ │ ├── TestBinding.wsdl │ │ │ ├── TestService.wsdl │ │ │ ├── testservice1.xsd │ │ │ └── testservice2.xsd │ │ ├── test06/ │ │ │ ├── TestService.wsdl │ │ │ └── wsdls/ │ │ │ ├── TestBinding.wsdl │ │ │ └── xsds/ │ │ │ ├── sub/ │ │ │ │ └── testservice2.xsd │ │ │ └── testservice1.xsd │ │ ├── test07/ │ │ │ ├── TestService.wsdl │ │ │ └── wsdls/ │ │ │ ├── TestBinding.wsdl │ │ │ └── xsds/ │ │ │ ├── sub/ │ │ │ │ └── testservice2.xsd │ │ │ └── testservice1.xsd │ │ ├── test08/ │ │ │ ├── TestService.wsdl │ │ │ └── wsdls/ │ │ │ ├── TestBinding.wsdl │ │ │ ├── testservice2.xsd │ │ │ └── xsds/ │ │ │ └── testservice1.xsd │ │ ├── test09/ │ │ │ ├── TestService.wsdl │ │ │ ├── common.xsd │ │ │ ├── one.xsd │ │ │ └── two.xsd │ │ ├── test10/ │ │ │ ├── TestService.wsdl │ │ │ ├── testservice1.xsd │ │ │ └── testservice2.xsd │ │ ├── test11/ │ │ │ └── TestService.wsdl │ │ ├── test12/ │ │ │ └── TestService.wsdl │ │ ├── test13/ │ │ │ ├── TestService.wsdl │ │ │ └── chameleon.xsd │ │ ├── test14/ │ │ │ └── TestService.wsdl │ │ ├── test15/ │ │ │ ├── TestService.wsdl │ │ │ └── stockquote-schema.xsd │ │ ├── test16/ │ │ │ ├── TestService.wsdl │ │ │ └── stockquote-schema.xsd │ │ ├── test17/ │ │ │ ├── TestService.wsdl │ │ │ └── stockquote-schema.xsd │ │ ├── test18/ │ │ │ └── TestService.wsdl │ │ ├── test19/ │ │ │ └── TestService.wsdl │ │ ├── test20/ │ │ │ └── TestService.wsdl │ │ ├── test22/ │ │ │ └── TestService.wsdl │ │ ├── test23/ │ │ │ └── TestService.wsdl │ │ ├── test25/ │ │ │ ├── TestService.wsdl │ │ │ └── info.txt │ │ ├── test26/ │ │ │ └── TestService.wsdl │ │ └── test27/ │ │ ├── TestService.wsdl │ │ └── info.txt │ └── wsdl/ │ ├── doc.literal/ │ │ ├── stockquote-schema.xsd │ │ └── stockquote-ws.wsdl │ ├── rpc.encoded/ │ │ ├── friend-ws.wsdl │ │ ├── stockquote-schema.xsd │ │ └── stockquote-ws.wsdl │ └── rpc.literal/ │ ├── stockquote-schema.xsd │ └── stockquote-ws.wsdl ├── soap-legacy/ │ ├── pom.xml │ └── src/ │ └── main/ │ ├── java/ │ │ └── org/ │ │ └── reficio/ │ │ └── ws/ │ │ └── legacy/ │ │ ├── AbstractSoapVersion.java │ │ ├── Constants.java │ │ ├── DefinitionLoader.java │ │ ├── SampleXmlUtil.java │ │ ├── SchemaDefinitionWrapper.java │ │ ├── SchemaLoader.java │ │ ├── SchemaUtils.java │ │ ├── SoapLegacyFacade.java │ │ ├── SoapMessageBuilder.java │ │ ├── SoapVersion.java │ │ ├── SoapVersion11.java │ │ ├── SoapVersion12.java │ │ ├── UrlSchemaLoader.java │ │ ├── WsdlContext.java │ │ ├── WsdlSettings.java │ │ ├── WsdlUtils.java │ │ ├── WsdlValidator.java │ │ └── XmlUtils.java │ └── resources/ │ ├── license.txt │ └── xsds/ │ ├── XMLSchema.xsd │ ├── soapEncoding.xsd │ ├── soapEncoding12.xsd │ ├── soapEnvelope.xsd │ ├── soapEnvelope12.xsd │ ├── swaref.xsd │ ├── xmime200411.xsd │ ├── xmime200505.xsd │ ├── xml.xsd │ └── xop.xsd ├── soap-server/ │ ├── pom.xml │ └── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── org/ │ │ │ └── reficio/ │ │ │ └── ws/ │ │ │ └── server/ │ │ │ ├── OperationNotFoundException.java │ │ │ ├── ServiceRegistrationException.java │ │ │ ├── SoapServerException.java │ │ │ ├── core/ │ │ │ │ ├── SoapServer.java │ │ │ │ ├── SoapServerConstants.java │ │ │ │ └── SoapServerFactory.java │ │ │ ├── endpoint/ │ │ │ │ ├── ContextEndpointAdapter.java │ │ │ │ ├── ContextPayloadEndpoint.java │ │ │ │ ├── GenericContextDomEndpoint.java │ │ │ │ ├── GenericEndpointMapping.java │ │ │ │ └── GenericSoapMessage.java │ │ │ ├── matcher/ │ │ │ │ ├── AggregatingVisitor.java │ │ │ │ ├── BindingOperationVisitor.java │ │ │ │ └── SoapOperationMatcher.java │ │ │ ├── protocol/ │ │ │ │ ├── GenericSoapMessageFactory.java │ │ │ │ ├── SimpleSoapProtocolChooser.java │ │ │ │ └── SoapProtocolChooser.java │ │ │ └── responder/ │ │ │ ├── AbstractResponder.java │ │ │ ├── AutoResponder.java │ │ │ └── RequestResponder.java │ │ └── resources/ │ │ ├── soap-server.xml │ │ └── soap-servlet.xml │ └── test/ │ ├── java/ │ │ └── org/ │ │ └── reficio/ │ │ └── ws/ │ │ └── server/ │ │ ├── PasswordLessKeystoreTest.java │ │ └── SimpleServerTest.java │ └── resources/ │ ├── keystores/ │ │ ├── .keystore │ │ ├── gen.sh │ │ └── keyless.keystore │ └── log4j.xml ├── soap-test/ │ ├── pom.xml │ └── src/ │ ├── main/ │ │ ├── groovy/ │ │ │ └── org/ │ │ │ └── reficio/ │ │ │ └── ws/ │ │ │ └── test/ │ │ │ └── spock/ │ │ │ ├── Server.groovy │ │ │ └── ServerExtension.groovy │ │ └── java/ │ │ └── org/ │ │ └── reficio/ │ │ └── ws/ │ │ └── test/ │ │ ├── ServerProcessor.java │ │ └── junit/ │ │ ├── Server.java │ │ └── SoapRule.java │ └── test/ │ ├── groovy/ │ │ └── org/ │ │ └── reficio/ │ │ └── ws/ │ │ └── test/ │ │ └── spock/ │ │ └── SpockExtensionTest.groovy │ ├── java/ │ │ └── org/ │ │ └── reficio/ │ │ └── ws/ │ │ └── test/ │ │ └── junit/ │ │ └── SoapRuleTest.java │ └── resources/ │ ├── log4j.xml │ └── wsdl/ │ ├── TestService.wsdl │ ├── currency-convertor.wsdl │ ├── testservice1.xsd │ └── testservice2.xsd └── src/ ├── main/ │ └── resources/ │ ├── findbugs-exclude.xml │ └── license.txt └── site/ ├── fml/ │ └── faq.fml └── site.xml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Compiled source # ################### *.com *.class *.dll *.exe *.o *.so # Packages # ############ # it's better to unpack these files and commit the raw source # git has its own built in compression methods *.7z *.dmg *.gz *.iso *.jar *.rar *.tar *.zip # Logs and databases # ###################### *.log *.sql *.sqlite # OS generated files # ###################### .DS_Store? ehthumbs.db Icon? Thumbs.db # Custom # ###################### target bin classes *.ipr *.iws *.iml .svn .classpath .project .idea src/site/markdown/*.* .DS_Store ================================================ FILE: .travis.yml ================================================ language: java jdk: - oraclejdk7 ================================================ FILE: README.md ================================================ # soap-ws [![Build Status](http://img.shields.io/travis/reficio/soap-ws.svg)](http://travis-ci.org/reficio/soap-ws) ## A lightweight and easy-to-use Java library to handle SOAP on a purely XML level. ### Intro Welcome to soap-ws! This is a lightweight and easy-to-use Java library that wraps Spring-WS and enables handling SOAP on a purely XML level. soap-ws is based on four main abstractions: * WsdlParser can easily parse your WSDL and produce SoapBuilders, * SoapBuilder can generate SOAP messages directly in the XML format, * SoapClient can be used to transmit a SOAP message over HTTP(s) to a web-service endpoint, * SoapServer can be leveraged to process SOAP messages and and respond to them. All of that requires no generation of stubs - everything happens directly in XML having - is the provider. ### Why should you use soap-ws? Read this carefully and check if you know what we are talking about. * Have you ever had problems with the versioning of web-service endpoints? Have you ever had to address the problem how to deal with many versions of the same classes generated from two versions of the same WSDL in one code base? Did you try to prefix the classes, change the package, or do any other mambo-jumbo tricks that are clearly against the best-practices of software design? * Have you every tried to chain and orchestrate a few web-service invocations applying some XSLT transformation to the consecutive responses forwarding them to the next endpoint? Have you ever seen how cumbersome it is using Java generated ws clients/servers? * Have you ever had to re-generate the ws-stubs, recompile and redeploy you application because of a tiny change in the WSDL? * Have you every been confused why you generate all these domain and stub classes to invoke one simple web-service operation and to get a plain response that could be processed with XSTL one-liner? * Have you ever had to had to send a simple XML message to a SOAP server in a fire and forget mode? * Have you ever had to expose a mock SOAP endpoint that would respond to the request sending a sample response -let's say in an unit test? * Have you ever had to download a hierarchical WSDL file with hierarchical XSD schemas and store it on your local hard drive with all the import and includes fixed properly so that you can reuse it locally? * Have you ever… Yes, that's what soap-ws can do for you. But it can do much more, just dive in and check the plethora of stuff that we have implemented. ### What is supported? * supports WSDL 1.1 * supports SOAP 1.1 and 1.2 * supports all four WS flavors: rpc-encoded, rpc-literal, document-literal and document-encoded * supports SSL and basic-authentication * supports SOCKS, HTTP and HTTPS proxies * supports SpringFramework * supports JUnit, Spock and Arquillian ### Main features soap-builder: * fetch, parse and store WSDL (hierarchical WSDLs and XSDs supported) * generate a soap XML message on the basis of the imported WSDL soap-client: * communication and message handling purely in the XML format * basic authentication and SSL support * HTTP(s) and SOCKS proxy support, with/without basic authentication soap-server: * endpoint exposition - communication and message handling purely in the XML format * extensive operation matcher - validate and match a request to a BindingOperation from the WSDL * auto-responder - respond to a soap request with a sample content * HTTP and HTTPS support ### License The project is open-source and distributed under the Apache license, Version 2.0. One module (soap-legacy) is distributed under the LGPL 2.1 license (see the Note). You can confidently use soap-ws in your commercial project. ## User Guide ### Quick-start #### Add soap-ws to your maven project In order to use soap-ws in your project you have to declare soap-ws in the dependencies section of your pom.xml. You can mix and match soap-builder, soap-client, soap-server artifacts, depending on the fact what you want to achieve. ```xml org.reficio soap-builder 1.0.0-SNAPSHOT org.reficio soap-client 1.0.0-SNAPSHOT org.reficio soap-server 1.0.0-SNAPSHOT ``` soap-ws is not yet located in the central maven repo, thus you also have to add an additional repository to your config. ```xml reficio http://repo.reficio.org/maven/ ``` If you are a Gradle user you probably know how to do it :) #### Consume a Web-Serivce in 60 seconds Let's consume the CurrencyConverter Web-Service. Thanks to the fluent builders the API is straigtforward and intuitive. Does it need any explanation? Welcome to soap-ws :) ```java Wsdl wsdl = Wsdl.parse("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL"); SoapBuilder builder = wsdl.binding() .localPart("CurrencyConvertorSoap") .find(); SoapOperation operation = builder.operation() .soapAction("http://www.webserviceX.NET/ConversionRate") .find(); Request request = builder.buildInputMessage(operation) SoapClient client = SoapClient.builder() .endpointUrl("http://www.webservicex.net/CurrencyConvertor.asmx") .build(); String response = client.post(request); ``` #### Provide a Web-Service in 60 seconds Let's provide the CurrencyConverter Web-Service that returns random results (compliant with the schema!). ```java Wsdl wsdl = Wsdl.parse("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL"); SoapBuilder builder = wsdl.binding() .localPart("CurrencyConvertorSoap") .find(); SoapServer server = SoapServer.builder() .httpPort(9090) .build(); server.registerRequestResponder("/currencyConvertor", new AutoResponder(builder)); server.start(); ``` That's more or less what you need to generate a SOAP message and consume/provide a Web-Service. ### API Let's have a closer look at the API and the main abstractions. #### SoapBuilder SoapBuilder interface describes the features of generation of XML SOAP messages. An instance of the SoapBuilder class is always bound to a specific wsdl file and one of its bindings. There can be more bindings in one WSDL file - in order to handle all of theme an instance of SoapBuilder is needed for every binding. The simplest way to construct an instance of the Wsdl is to call the static factory method "parse", passing the URL of the WSDL file (1). ```java Wsdl wsdl = Wsdl.parse(wsdlUrl); // (1) List bindings = wsdl.getBindings(); // (2) SoapBuilder builder = wsdl.binding().localPart("CurrencyConvertorSoap").find(); // (3) wsdl.printBindings(); // (4) List operations = builder.getOperations(); // (5) SoapOperation operation = builder.operation().name("ConversionRate").find(); // (6) ``` Wsdl.parse(wsdlUrl) reads the specified WSDL file recursively, fetching all included WSDL and XSD files and constructs an underlying javax.wsdl.Definition object that is the Java-based representation of the WSDL (see WSDL4j to read more about the Definitoin object). In order to generate a SOAP message you have to specify the Binding. To check what binding are defined in the WSDL invoke the getBindings() method (2). You can also use the binding finder, just call the binding() method and add additional parameters such as localPart(""), etc. Then invoke builder to get an instance of the SoapBuilder(). Finally, you can invoke the printBindings() method that will print all the binding to the stdout (just as a quick hack) (4). The last step is to generate a SOAP message using the SoapBuilder. In order to do it though you have to specify the SOAP operation. In order to get the list of operations specified in that binding just invoke the getOperations() method on the SoapBuilder object (5). You can also use the SOAP operation finder - just call the operation() method and chain additional parameters such as name(), etc. Then call find() and get a reference to the Soap Operation. Now you are all set. To generate a SOAP message in the XML format just invoke one of the methods defined in the SoapBuilder interface specifiying the SoapOperation. You can also build generic empty messages invoking buildEmptyMessage or buildFault: ```java public interface SoapBuilder { String buildInputMessage(SoapOperation operation); String buildInputMessage(SoapOperation operation, SoapContext context); String buildOutputMessage(SoapOperation operation); String buildOutputMessage(SoapOperation operation, SoapContext context); String buildFault(String code, String message); String buildFault(String code, String message, SoapContext context); String buildEmptyFault(); String buildEmptyFault(SoapContext context); String buildEmptyMessage(); // (…) } ``` Last, but not least. In most of the cases, you can relay on the default settings of the SoapContext that specifies how messages are generated, but if you would like to change it you have to populate the SoapContext object and pass it either to the Wsdl (from that moment on, SoapBuilder will use this context as the default one), or to single methods, changing the context of the generation for the time span of a single method invocation. In order to populate a SoapContext object use the fluent builder presented below. ```java SoapContext context = SoapContext.builder() .alwaysBuildHeaders(true) .buildOptional(true) .exampleContent(true) .typeComment(true) .skipComments(false) .build(); ``` #### SoapClient You can create an instance of a soap-client using a fluent builder. If you want to use a plain HTTP connection without tweaking any advance options you are good to go with the following snippet: ```java SoapClient client = SoapClient.builder() .endpointUrl("http://example.com/endpoint") .build(); ``` Then, you can send a SOAP envelope (as a String) invoking the post() method: ```java client.post(soapAction, envelope); ``` You can also skip the SOAPAction header and send the envelope only: ```java client.post(envelope); ``` #### SoapServer Use a similar builder to create an instance of the soap-server. ```java SoapServer server = SoapServer.builder() .httpPort(8080) .build(); ``` You can start and stop the server using start/stop methods ```java server.start(); server.stop(); ``` Now we would like to turn our server into a mock server that responds to request generating a sample content that is complaint with the schema of the operation that is being invoked. To do that we have to create an AutoResponder and register it under the given context path. Autoresponder requires a populated SoapBuilder instance (that contains the WSDL and the binding name which it should use). Keep in mind the there can be only one binding under one context path; ```java String contextPath = "/exampleEndpoint"; AutoResponder responder = new AutoResponder(soapBuilder); server.registerResponder(contextPath, responder); ``` From that moment our server will respond to request send to the "exampleEndpoint" context path. If you would like to handle the request yourself you just have to implement the RequestResponder interface. ```java public interface RequestResponder { java.xml.Source respond(SoapMessage request); } ``` It may be a bit cumbersome, as it is not that easy to match an XML request to the binding and operation, that is the reason why we provided an AbstractResponder that does all of that backstage. ```java public abstract class AbstractResponder implements RequestResponder { // (…) /** * Abstract method that should be implemented by overriding classes. * This method is invoked whenever a request is send by the client. * InvokedOperation may be passed to a SoapBuilder to construct the * response to the request that was sent by the client. * * @param invokedOperation operation from the binding that is matched to the SOAP message * @param message SOAP message passed by the client * @return response in the XML source format containing the whole SOAP envelope */ public abstract Source respond(SoapOperation invokedOperation, SoapMessage message); } ``` AbstractResponder does all the hard work for you to match the message to the BindingOperation from the WSDL. If it find it the respond() operation is invoked, if not a SOAP fault is send back to the client saying the operation has not been found. AbstractResponder uses our implementation of the SoapOperationMatcher that matches the request to the operation in the following way: * SOAP Action mapping * RCP bindings are matched using single top-level tag with the name of the invoked operation * Document bindings are matched by input types and then by input names Having the SoapOperation object provided by the AbstractResponder you can easily generate and modify the response that you create using SoapBuilder that available in the responder as a instance field called builder. That's a lot of stuff. I hope you enjoyed it! Have a look at the examples located in the soap-examples project. Try it out now and leave send us some feedback! ### Project modules * soap-builder - responsible for the generation of SOAP XML messages. * soap-client - responsible for the communication with a SOAP endpoint. * soap-server - responsible for exposing SOAP endpoints and handling the requests. * soap-it - contains integration tests - tests soap-client and soap-server in many tricky ways. * soap-examples - contains a few example how to use soap-ws. * soap-legacy - legacy code extracted from 3rd party projects ### Example usage #### Generate and post a SOAP message ```java Wsdl wsdl = Wsdl.parse("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL"); SoapBuilder builder = wsdl.binding() .localPart("CurrencyConvertorSoap") .find(); SoapOperation operation = builder.operation() .soapAction("http://www.webserviceX.NET/ConversionRate") .find(); Request request = builder.buildInputMessage(operation) SoapClient client = SoapClient.builder() .endpointUrl("http://www.webservicex.net/CurrencyConvertor.asmx") .build(); String response = client.post(request); ``` #### Create a SoapServer ```java SoapServer server = SoapServer.builder() .httpPort(9090) .build(); server.start(); ``` #### Create a SoapServer with AutoResponder (great to unit test web-services) ```java SoapServer server = SoapServer.builder() .httpPort(9090) .build(); server.start(); URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath("/", "wsdl/stockquote-service.wsdl"); Wsdl wsdl = Wsdl.parse(wsdlUrl); SoapBuilder builder = wsdl.binding().localPart("StockQuoteSoapBinding").find(); AutoResponder responder = new AutoResponder(builder); server.registerRequestResponder("/service", responder); server.stop(); ``` #### Create a SoapServer with a custom responder ```java SoapServer server = SoapServer.builder() .httpPort(9090) .build(); server.start(); URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath("/", "wsdl/stockquote-service.wsdl"); Wsdl wsdl = Wsdl.parse(wsdlUrl); final SoapBuilder builder = wsdl.binding().localPart("StockQuoteSoapBinding").find(); AbstractResponder customResponder = new AbstractResponder(builder) { @Override public Source respond(SoapOperation invokedOperation, SoapMessage message) { try { // build the response using builder String response = builder.buildOutputMessage(invokedOperation); // here you can tweak the response -> for example with XSLT //... return XmlUtils.xmlStringToSource(response); } catch (Exception e) { // will automatically generate SOAP-FAULT throw new RuntimeException("my custom error", e); } } }; server.registerRequestResponder("/service", customResponder); ``` You can find all these working examples in the soap-examples project. Enjoy! #### Spring example Spring configuration: ```xml wsdl/currency-convertor.wsdl http://www.webservicex.net/CurrencyConvertor.asmx?WSDL {http://www.webserviceX.NET/}CurrencyConvertorSoap ``` Then you can inject the beans to your code, for example in such a way: ```java @Autowired private SoapBuilder builder; @Autowired private SoapClient client; @Autowired private SoapServer server; ``` ## Last but not least ### How can I hack around? * GitHub -> https://github.com/reficio/soap-ws * Jenkins -> https://reficio.ci.cloudbees.com/job/soap-ws/ * Site -> http://projects.reficio.org/soap-ws/1.0.0-SNAPSHOT/manual.html ### Who's behind it? Tom Bujok [tom.bujok@gmail.com] ### History This project was initially developed at centeractive ag for the purposes of the open-sphere project. The library has been successfully incorporated into open-sphere and that initial version could be found in the centeractive's repository at github. Currently the project is developed and maintained solely by Tom Bujok at reficio.org ### Note This project contains classes extracted from the soapUI code base by centeractive ag in October 2011. They are located in the soap-legacy module. Every extracted class is annotated with an comment to fulfill the requirements of the LGPL 2.1 license under which soapUI is released. That is also the reason why soap-legacy module is released under LGPL 2.1 license. All other soap-ws modules are released under Apache v.2 license. The main reason behind the class extraction was to separate the code that is responsible for the generation of the SOAP messages from the rest of the soapUI's code that is tightly coupled with other modules, such as soapUI's graphical user interface, etc. The goal was to create an open-source java project whose main responsibility is to handle SOAP message generation and SOAP transmission purely on an XML level. centeractive ag would like to express strong appreciation to SmartBear Software and to the whole team of soapUI's developers for creating soapUI and for releasing its source code under a free and open-source license. centeractive ag extracted and modified some parts of the soapUI's code in good faith, making every effort not to impair any existing functionality and to supplement it according to our requirements, applying best practices of software design. [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/reficio/soap-ws/trend.png)](https://bitdeli.com/free "Bitdeli Badge") ================================================ FILE: pom.xml ================================================ 4.0.0 org.reficio soap-ws pom 1.0.0-SNAPSHOT soap-ws soap-ws is a lightweight and easy-to-use Java library to handle SOAP message generation and SOAP message transmission on a purely XML level. With the usage of this library within few lines of code you can easily import your WSDL and generate SOAP messages directly in an XML format. Then you can use the SoapClient to transmit this message over HTTP(s) to a web-service endpoint. Finally, you can run SoapServer to receive SOAP messages and and respond to them. And all of that requires no classes or stubs generation - everything happens directly in an XML format. http://projects.reficio.org/soap-ws/${project.version} UTF-8 1.5 2.0 2.1.2 soap-common soap-legacy soap-builder soap-client soap-server soap-it soap-examples soap-test The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo 2012 tom.bujok Tom Bujok tom.bujok@gmail.com reficio http://www.reficio.org project lead developer +1 github https://github.com/reficio/soap-ws/issues scm:git:git://github.com/reficio/soap-ws.git scm:git:git@github.com:reficio/soap-ws.git http://github.com/reficio/soap-ws jenkins https://reficio.ci.cloudbees.com/job/soap-ws/ org.apache.commons commons-lang3 3.1 commons-io commons-io 2.3 commons-logging commons-logging 1.1.1 commons-codec commons-codec 1.6 log4j log4j 1.2.17 junit junit 4.11 org.spockframework spock-core 0.7-groovy-2.0 com.googlecode.guava-osgi guava-osgi 11.0.1 org.apache.ws.commons.schema XmlSchema 1.4.5 org.codehaus.gmaven.runtime gmaven-runtime-2.0 ${gmaven.version} org.codehaus.groovy groovy-all org.codehaus.groovy groovy-all ${groovy.version} maven-compiler-plugin 2.5.1 1.6 1.6 UTF-8 org.codehaus.gmaven gmaven-plugin ${gmaven.version} ${gmaven.provider.selection} UTF-8 generateStubs compile generateTestStubs testCompile org.codehaus.groovy groovy-all ${groovy.version} com.mycila.maven-license-plugin maven-license-plugin 1.10.b1 true ${basedir}
src/main/resources/license.txt
false true false src/** **/test/** target/** **/resources/** .clover/** true XML_STYLE XML_STYLE JAVADOC_STYLE true ${project.inceptionYear}-2013 Reficio (TM) - Reestablish your software! UTF-8
compile check
org.apache.felix maven-bundle-plugin 2.3.4 true true ${project.artifactId} ${project.version} ${project.artifactId} ${project.groupId}.${project.artifactId} * !* <_versionpolicy-impl>[$(version;==;$(@)),$(version;=+;$(@))) <_versionpolicy-uses>[$(version;==;$(@)),$(version;+;$(@))) <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@))) <_failok>false org.apache.maven.plugins maven-jar-plugin 2.3.1 test-jar org.apache.maven.plugins maven-source-plugin 2.1.2 attach-sources jar org.apache.maven.plugins maven-javadoc-plugin 2.8.1 attach-javadocs jar true org.apache.maven.plugins maven-site-plugin 3.1 org.apache.maven.doxia doxia-module-markdown 1.3 org.apache.maven.plugins maven-project-info-reports-plugin 2.2 false false index project-team help cim issue-tracking license scm summary org.apache.maven.plugins maven-javadoc-plugin 2.8.1 org.apache.maven.plugins maven-jxr-plugin 2.2 true jxr test-jxr com.atlassian.maven.plugins maven-clover2-plugin 3.1.7 ${user.home}/clover/soap-ws/cloverMerged.db
org.apache.maven.wagon wagon-ftp 2.2 org.apache.maven.wagon wagon-ssh 2.2
reficio http://repo.reficio.org/maven/ eviware http://www.eviware.com/repository/maven2/ jboss https://repository.jboss.org/nexus/content/repositories/deprecated/ servicemix http://svn.apache.org/repos/asf/servicemix/m2-repo/ clover com.atlassian.maven.plugins maven-clover2-plugin 3.1.7 ${user.home}/clover/soap-ws/cloverMerged.db true true true true site README.md maven-antrun-plugin 1.7 modify-markdown pre-site false run default-cli run org.apache.ant ant-jsch 1.8.4 com.jcraft jsch 0.1.48 findbugs org.codehaus.mojo findbugs-maven-plugin 2.4.0 findbugs compile findbugs true src/main/resources/findbugs-exclude.xml reficio Reficio Maven Repository scp://${reficio.server}/var/www/repo/maven
================================================ FILE: soap-builder/pom.xml ================================================ 4.0.0 org.reficio soap-builder bundle soap-builder - XML based SOAP message generator org.reficio soap-ws 1.0.0-SNAPSHOT ../pom.xml The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo org.reficio soap-common ${project.version} org.reficio soap-legacy ${project.version} junit junit test org.apache.maven.plugins maven-site-plugin 3.1 true ================================================ FILE: soap-builder/src/main/java/org/reficio/ws/builder/SoapBuilder.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder; import org.reficio.ws.SoapContext; import javax.wsdl.Binding; import javax.xml.namespace.QName; import java.util.List; /** * @author Tom Bujok * @since 1.0.0 */ public interface SoapBuilder { List getOperations(); SoapOperationFinder operation(); SoapContext getContext(); SoapOperationBuilder getOperationBuilder(SoapOperation operation); String buildInputMessage(SoapOperation operation); String buildInputMessage(SoapOperation operation, SoapContext context); String buildOutputMessage(SoapOperation operation); String buildOutputMessage(SoapOperation operation, SoapContext context); String buildFault(String code, String message); String buildFault(String code, String message, SoapContext context); String buildEmptyFault(); String buildEmptyFault(SoapContext context); String buildEmptyMessage(); String buildEmptyMessage(SoapContext context); QName getBindingName(); Binding getBinding(); List getServiceUrls(); void validateInputMessage(SoapOperation operation, String message); void validateInputMessage(SoapOperation operation, String message, boolean strict); void validateOutputMessage(SoapOperation operation, String message); void validateOutputMessage(SoapOperation operation, String message, boolean strict); boolean isRpc(); boolean isInputSoapEncoded(SoapOperation operation); boolean isOutputSoapEncoded(SoapOperation operation); } ================================================ FILE: soap-builder/src/main/java/org/reficio/ws/builder/SoapBuilderFinder.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder; import org.reficio.ws.SoapContext; import javax.xml.namespace.QName; /** * @author Tom Bujok * @since 1.0.0 */ public interface SoapBuilderFinder { SoapBuilderFinder name(String name); SoapBuilderFinder name(QName name); SoapBuilderFinder namespaceURI(String namespaceURI); SoapBuilderFinder localPart(String localPart); SoapBuilderFinder prefix(String prefix); SoapBuilder find(); SoapBuilder find(SoapContext context); } ================================================ FILE: soap-builder/src/main/java/org/reficio/ws/builder/SoapOperation.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder; import javax.xml.namespace.QName; /** * Wrapper object that represents one operation from a WSDL's binding * * @author Tom Bujok * @since 1.0.0 */ public interface SoapOperation { QName getBindingName(); String getOperationName(); String getOperationInputName(); String getOperationOutputName(); String getSoapAction(); boolean isRpc(); boolean isInputSoapEncoded(); boolean isOutputSoapEncoded(); } ================================================ FILE: soap-builder/src/main/java/org/reficio/ws/builder/SoapOperationBuilder.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder; import org.reficio.ws.SoapContext; /** * @author Tom Bujok * @since 1.0.0 */ public interface SoapOperationBuilder extends SoapOperation { void setContext(SoapContext context); SoapContext getContext(); String buildInputMessage(); String buildInputMessage(SoapContext context); String buildOutputMessage(); String buildOutputMessage(SoapContext context); String buildFault(String code, String message); String buildFault(String code, String message, SoapContext context); String buildEmptyFault(); String buildEmptyFault(SoapContext context); String buildEmptyMessage(); String buildEmptyMessage(SoapContext context); void validateInputMessage(String message); void validateInputMessage(String message, boolean strict); void validateOutputMessage(String message); void validateOutputMessage(String message, boolean strict); } ================================================ FILE: soap-builder/src/main/java/org/reficio/ws/builder/SoapOperationFinder.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder; import org.reficio.ws.SoapContext; /** * @author Tom Bujok * @since 1.0.0 */ public interface SoapOperationFinder { SoapOperationFinder name(String operationName); SoapOperationFinder soapAction(String soapAction); SoapOperationFinder inputName(String inputName); SoapOperationFinder outputName(String inputName); SoapOperationBuilder find(); SoapOperationBuilder find(SoapContext context); } ================================================ FILE: soap-builder/src/main/java/org/reficio/ws/builder/core/SoapBuilderImpl.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder.core; import org.reficio.ws.SoapBuilderException; import org.reficio.ws.SoapContext; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.SoapOperation; import org.reficio.ws.builder.SoapOperationBuilder; import org.reficio.ws.builder.SoapOperationFinder; import org.reficio.ws.legacy.SoapLegacyFacade; import javax.wsdl.Binding; import javax.wsdl.BindingOperation; import javax.wsdl.Port; import javax.wsdl.Service; import javax.xml.namespace.QName; import java.util.ArrayList; import java.util.Collection; import java.util.List; /** * @author Tom Bujok * @since 1.0.0 */ class SoapBuilderImpl implements SoapBuilder { private final SoapLegacyFacade soapFacade; private final Binding binding; private final SoapContext context; private final List serviceUrls; SoapBuilderImpl(SoapLegacyFacade soapFacade, Binding binding, SoapContext context) { this.soapFacade = soapFacade; this.binding = binding; this.context = context; this.serviceUrls = new ArrayList(); initializeServiceUrls(); } @SuppressWarnings("unchecked") private void initializeServiceUrls() { for (Service service : soapFacade.getServices()) { for (Port port : (Collection) service.getPorts().values()) { String address = SoapLegacyFacade.getSoapEndpoint(port); if (address != null) { serviceUrls.add(address); } } } } public BindingOperation getBindingOperation(SoapOperation op) { BindingOperation operation = binding.getBindingOperation(op.getOperationName(), op.getOperationInputName(), op.getOperationOutputName()); if (operation == null) { throw new SoapBuilderException("Operation not found"); } return operation; } @Override @SuppressWarnings("unchecked") public List getOperations() { List operationNames = new ArrayList(); for (BindingOperation operation : (List) binding.getBindingOperations()) { operationNames.add(SoapOperationImpl.create(this, binding, operation)); } return operationNames; } @Override public SoapContext getContext() { return context; } @Override public SoapOperationBuilder getOperationBuilder(SoapOperation operation) { BindingOperation bindingOperation = getBindingOperation(operation); return SoapOperationImpl.create(this, binding, bindingOperation); } @Override public SoapOperationFinder operation() { return new SoapOperationFinderImpl(this, binding); } @Override public String buildInputMessage(SoapOperation operation) { return buildInputMessage(operation, context); } @Override public String buildInputMessage(SoapOperation operation, SoapContext context) { try { return soapFacade.buildSoapMessageFromInput(binding, getBindingOperation(operation), context); } catch (Exception e) { throw new SoapBuilderException(e); } } @Override public String buildOutputMessage(SoapOperation operation) { return buildOutputMessage(operation, context); } @Override public String buildOutputMessage(SoapOperation operation, SoapContext context) { try { return soapFacade.buildSoapMessageFromOutput(binding, getBindingOperation(operation), context); } catch (Exception e) { throw new SoapBuilderException(e); } } @Override public String buildFault(String code, String message) { return soapFacade.buildFault(code, message, binding, context); } @Override public String buildFault(String code, String message, SoapContext context) { return soapFacade.buildFault(code, message, binding, context); } @Override public String buildEmptyFault() { return soapFacade.buildEmptyFault(binding, context); } @Override public String buildEmptyFault(SoapContext context) { return soapFacade.buildEmptyFault(binding, context); } @Override public String buildEmptyMessage() { return soapFacade.buildEmptyMessage(binding, context); } @Override public String buildEmptyMessage(SoapContext context) { return soapFacade.buildEmptyMessage(binding, context); } @Override public QName getBindingName() { return binding.getQName(); } @Override public Binding getBinding() { return binding; } @Override public List getServiceUrls() { return new ArrayList(serviceUrls); } @Override public void validateInputMessage(SoapOperation operation, String message) { BindingOperation bindingOperation = getBindingOperation(operation); soapFacade.validateSoapRequestMessage(binding, bindingOperation, message, false); } @Override public void validateInputMessage(SoapOperation operation, String message, boolean strict) { BindingOperation bindingOperation = getBindingOperation(operation); soapFacade.validateSoapRequestMessage(binding, bindingOperation, message, strict); } @Override public void validateOutputMessage(SoapOperation operation, String message) { BindingOperation bindingOperation = getBindingOperation(operation); soapFacade.validateSoapResponseMessage(binding, bindingOperation, message, false); } @Override public void validateOutputMessage(SoapOperation operation, String message, boolean strict) { BindingOperation bindingOperation = getBindingOperation(operation); soapFacade.validateSoapResponseMessage(binding, bindingOperation, message, strict); } @Override public boolean isRpc() { return SoapLegacyFacade.isRpc(binding); } @Override public boolean isInputSoapEncoded(SoapOperation operation) { return soapFacade.isInputSoapEncoded(getBindingOperation(operation)); } @Override public boolean isOutputSoapEncoded(SoapOperation operation) { return soapFacade.isOutputSoapEncoded(getBindingOperation(operation)); } } ================================================ FILE: soap-builder/src/main/java/org/reficio/ws/builder/core/SoapOperationFinderImpl.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder.core; import com.google.common.base.Preconditions; import org.reficio.ws.SoapBuilderException; import org.reficio.ws.SoapContext; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.SoapOperationBuilder; import org.reficio.ws.builder.SoapOperationFinder; import javax.wsdl.Binding; import javax.wsdl.BindingOperation; import java.util.ArrayList; import java.util.List; /** * @author Tom Bujok * @since 1.0.0 */ class SoapOperationFinderImpl implements SoapOperationFinder { private final Binding binding; private String operationName; private String operationInputName; private String operationOutputName; private String soapAction; private SoapBuilder builder; SoapOperationFinderImpl(SoapBuilder builder, Binding binding) { this.binding = binding; this.builder = builder; } @Override public SoapOperationFinder name(String operationName) { Preconditions.checkNotNull(operationName); this.operationName = operationName; return this; } @Override public SoapOperationFinder soapAction(String soapAction) { Preconditions.checkNotNull(soapAction); this.soapAction = soapAction; return this; } @Override public SoapOperationFinder inputName(String inputName) { Preconditions.checkNotNull(inputName); this.operationInputName = inputName; return this; } @Override public SoapOperationFinder outputName(String outputName) { Preconditions.checkNotNull(outputName); this.operationOutputName = outputName; return this; } @Override @SuppressWarnings("unchecked") public SoapOperationBuilder find() { validateInput(); List found = new ArrayList(); for (BindingOperation operation : (List) binding.getBindingOperations()) { boolean condition = true; condition &= checkOperationName(operation); condition &= checkSoapAction(operation); condition &= checkOperationInputName(operation); condition &= checkOperationOutputName(operation); if(condition) { found.add(SoapOperationImpl.create(builder, binding, operation)); if(found.size() > 1) { throw new SoapBuilderException("Operation not unique - found more than one operation"); } } } if(found.isEmpty()) { throw new SoapBuilderException("Found no operations"); } return found.iterator().next(); } @Override public SoapOperationBuilder find(SoapContext context) { SoapOperationBuilder builder = find(); builder.setContext(context); return builder; } private void validateInput() { boolean failed = true; failed &= this.operationName == null; failed &= this.soapAction == null; failed &= this.operationInputName == null; failed &= this.operationOutputName == null; if(failed) { throw new IllegalArgumentException("All finder properties cannot be null"); } } private boolean checkOperationName(BindingOperation op) { if (this.operationName != null) { return this.operationName.equals(op.getOperation().getName()); } return true; } private boolean checkSoapAction(BindingOperation op) { if (this.soapAction != null) { return this.soapAction.equals(SoapUtils.getSOAPActionUri(op)); } return true; } private boolean checkOperationInputName(BindingOperation op) { if (this.operationInputName != null) { return this.operationInputName.equals(op.getOperation().getInput().getName()); } return true; } private boolean checkOperationOutputName(BindingOperation op) { if (this.operationOutputName != null) { return this.operationOutputName.equals(op.getOperation().getOutput().getName()); } return true; } } ================================================ FILE: soap-builder/src/main/java/org/reficio/ws/builder/core/SoapOperationImpl.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder.core; import org.reficio.ws.SoapContext; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.SoapOperation; import org.reficio.ws.builder.SoapOperationBuilder; import javax.wsdl.Binding; import javax.wsdl.BindingOperation; import javax.xml.namespace.QName; /** * @author Tom Bujok * @since 1.0.0 */ class SoapOperationImpl implements SoapOperation, SoapOperationBuilder { private final QName bindingName; private final String operationName; private final String operationInputName; private final String operationOutputName; private final String soapAction; private final SoapBuilder builder; private SoapContext context; SoapOperationImpl(SoapBuilder builder, QName bindingName, String operationName, String operationInputName, String operationOutputName, String soapAction) { this.builder = builder; this.bindingName = bindingName; this.operationName = operationName; this.operationInputName = operationInputName; this.operationOutputName = operationOutputName; this.soapAction = soapAction; this.context = builder.getContext(); } public QName getBindingName() { return bindingName; } public String getOperationName() { return operationName; } public String getOperationInputName() { return operationInputName; } public String getOperationOutputName() { return operationOutputName; } public String getSoapAction() { return soapAction; } @Override public boolean isRpc() { return builder.isRpc(); } @Override public boolean isInputSoapEncoded() { return builder.isInputSoapEncoded(this); } @Override public boolean isOutputSoapEncoded() { return builder.isOutputSoapEncoded(this); } static SoapOperationBuilder create(SoapBuilder builder, Binding binding, BindingOperation operation) { String soapAction = SoapUtils.getSOAPActionUri(operation); return create(builder, binding, operation, soapAction); } static SoapOperationBuilder create(SoapBuilder builder, Binding binding, BindingOperation operation, String soapAction) { String bindingInputName = operation.getBindingInput() != null ? operation.getBindingInput().getName() : null; String bindingOutputName = operation.getBindingOutput() != null ? operation.getBindingOutput().getName() : null; return new SoapOperationImpl(builder, binding.getQName(), operation.getName(), bindingInputName, bindingOutputName, SoapUtils.normalizeSoapAction(soapAction)); } public String toString() { return String.format("bindingName=[%s] operationName=[%s] operationInputName=[%s] operationOutputName=[%s] soapAction=[%s]", bindingName.toString(), operationName, operationInputName, operationOutputName, soapAction); } @Override public void setContext(SoapContext context) { this.context = context; } @Override public SoapContext getContext() { return builder.getContext(); } @Override public String buildInputMessage() { return builder.buildInputMessage(this, context); } @Override public String buildInputMessage(SoapContext context) { return builder.buildInputMessage(this, context); } @Override public String buildOutputMessage() { return builder.buildOutputMessage(this, context); } @Override public String buildOutputMessage(SoapContext context) { return builder.buildOutputMessage(this, context); } @Override public String buildFault(String code, String message) { return builder.buildFault(code, message, context); } @Override public String buildFault(String code, String message, SoapContext context) { return builder.buildFault(code, message, context); } @Override public String buildEmptyFault() { return builder.buildEmptyFault(context); } @Override public String buildEmptyFault(SoapContext context) { return builder.buildEmptyFault(context); } @Override public String buildEmptyMessage() { return builder.buildEmptyMessage(context); } @Override public String buildEmptyMessage(SoapContext context) { return builder.buildEmptyMessage(context); } @Override public void validateInputMessage(String message) { builder.validateInputMessage(this, message); } @Override public void validateInputMessage(String message, boolean strict) { builder.validateInputMessage(this, message, strict); } @Override public void validateOutputMessage(String message) { builder.validateOutputMessage(this, message); } @Override public void validateOutputMessage(String message, boolean strict) { builder.validateOutputMessage(this, message, strict); } } ================================================ FILE: soap-builder/src/main/java/org/reficio/ws/builder/core/SoapUtils.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder.core; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.SoapOperationBuilder; import javax.wsdl.Binding; import javax.wsdl.BindingOperation; import javax.wsdl.extensions.ExtensibilityElement; import javax.wsdl.extensions.soap.SOAPOperation; import javax.wsdl.extensions.soap12.SOAP12Operation; import java.util.List; /** * @author Tom Bujok * @since 1.0.0 */ public class SoapUtils { // removes "" from soap action public static String normalizeSoapAction(String soapAction) { String normalizedSoapAction = ""; if (soapAction != null && soapAction.length() > 0) { normalizedSoapAction = soapAction; if (soapAction.charAt(0) == '"' && soapAction.charAt(soapAction.length() - 1) == '"') { normalizedSoapAction = soapAction.substring(1, soapAction.length() - 1).trim(); } } return normalizedSoapAction; } public static String getSOAPActionUri(BindingOperation operation) { List extensions = operation.getExtensibilityElements(); if (extensions != null) { for (int i = 0; i < extensions.size(); i++) { ExtensibilityElement extElement = (ExtensibilityElement) extensions.get(i); if (extElement instanceof SOAPOperation) { SOAPOperation soapOp = (SOAPOperation) extElement; return soapOp.getSoapActionURI(); } else if (extElement instanceof SOAP12Operation) { SOAP12Operation soapOp = (SOAP12Operation) extElement; return soapOp.getSoapActionURI(); } } } return null; } public static SoapOperationBuilder createOperation(SoapBuilder builder, Binding binding, BindingOperation operation, String soapAction) { return SoapOperationImpl.create(builder, binding, operation, soapAction); } } ================================================ FILE: soap-builder/src/main/java/org/reficio/ws/builder/core/Wsdl.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder.core; import com.google.common.base.Preconditions; import org.apache.commons.lang3.StringUtils; import org.reficio.ws.SoapBuilderException; import org.reficio.ws.SoapContext; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.SoapBuilderFinder; import org.reficio.ws.legacy.SoapLegacyFacade; import javax.wsdl.Binding; import javax.wsdl.WSDLException; import javax.xml.namespace.QName; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; /** * @author Tom Bujok * @since 1.0.0 */ public final class Wsdl { private final URL wsdlUrl; private final SoapLegacyFacade soapFacade; private Wsdl(URL wsdlUrl) { try { this.wsdlUrl = wsdlUrl; this.soapFacade = new SoapLegacyFacade(wsdlUrl); } catch (WSDLException e) { throw new SoapBuilderException(e); } } public static Wsdl parse(URL wsdlUrl) { Preconditions.checkNotNull(wsdlUrl, "URL of the WSDL cannot be null"); return new Wsdl(wsdlUrl); } public static Wsdl parse(String wsdlUrl) { Preconditions.checkNotNull(wsdlUrl, "URL of the WSDL cannot be null"); try { return new Wsdl(new URL(wsdlUrl)); } catch (MalformedURLException e) { throw new SoapBuilderException(e); } } public List getBindings() { return soapFacade.getBindingNames(); } public SoapBuilderFinder binding() { return new SoapBuilderFinderImpl(); } public URL saveWsdl(File rootWsdl) { return soapFacade.saveWsdl(rootWsdl.getName(), rootWsdl.getParentFile()); } public static URL saveWsdl(URL wsdlUrl, File rootWsdl) { return SoapLegacyFacade.saveWsdl(wsdlUrl, rootWsdl.getName(), rootWsdl.getParentFile()); } public void printBindings() { System.out.println(wsdlUrl); for (QName bindingName : soapFacade.getBindingNames()) { System.out.println("\t" + bindingName.toString()); } } class SoapBuilderFinderImpl implements SoapBuilderFinder { SoapBuilderFinderImpl() { } private String namespaceURI; private String localPart; private String prefix; @Override public SoapBuilderFinder name(String name) { return name(QName.valueOf(name)); } @Override public SoapBuilderFinder name(QName name) { this.namespaceURI = name.getNamespaceURI(); this.localPart = name.getLocalPart(); this.prefix = name.getPrefix(); return this; } @Override public SoapBuilderFinder namespaceURI(String namespaceURI) { this.namespaceURI = namespaceURI; return this; } @Override public SoapBuilderFinder localPart(String localPart) { this.localPart = localPart; return this; } @Override public SoapBuilderFinder prefix(String prefix) { this.prefix = prefix; return this; } @Override public SoapBuilder find() { validate(); return getBuilder(getBindingName(), SoapContext.DEFAULT); } @Override public SoapBuilder find(SoapContext context) { validate(); return getBuilder(getBindingName(), context); } private QName getBindingName() { List result = new ArrayList(); for (QName bindingName : soapFacade.getBindingNames()) { if (bindingName.getLocalPart().equals(localPart)) { if (namespaceURI != null) { if (!bindingName.getNamespaceURI().equals(namespaceURI)) { continue; } } if (prefix != null) { if (!bindingName.getPrefix().equals(prefix)) { continue; } } result.add(bindingName); } } if (result.isEmpty()) { throw new SoapBuilderException("Binding not found"); } if (result.size() > 1) { throw new SoapBuilderException("Found more than one binding " + result); } return result.iterator().next(); } private void validate() { if (StringUtils.isBlank(localPart)) { throw new SoapBuilderException("Specify at least localPart of the binding's QName"); } } } public SoapBuilder getBuilder(String bindingName) { return getBuilder(bindingName, SoapContext.DEFAULT); } public SoapBuilder getBuilder(String bindingName, SoapContext context) { Preconditions.checkNotNull(bindingName, "BindingName cannot be null"); return getBuilder(QName.valueOf(bindingName), context); } public SoapBuilder getBuilder(QName bindingName) { return getBuilder(bindingName, SoapContext.DEFAULT); } public SoapBuilder getBuilder(QName bindingName, SoapContext context) { Preconditions.checkNotNull(bindingName, "BindingName cannot be null"); Preconditions.checkNotNull(context, "SoapContext cannot be null"); Binding binding = soapFacade.getBindingByName(bindingName); return new SoapBuilderImpl(soapFacade, binding, context); } } ================================================ FILE: soap-builder/src/main/resources/xsds/XMLSchema.xsd ================================================ ]> Part 1 version: Id: structures.xsd,v 1.2 2004/01/15 11:34:25 ht Exp Part 2 version: Id: datatypes.xsd,v 1.3 2004/01/23 18:11:13 ht Exp The schema corresponding to this document is normative, with respect to the syntactic constraints it expresses in the XML Schema language. The documentation (within <documentation> elements) below, is not normative, but rather highlights important aspects of the W3C Recommendation of which this is a part The simpleType element and all of its members are defined towards the end of this schema document This type is extended by almost all schema types to allow attributes from other namespaces to be added to user schemas. This type is extended by all types which allow annotation other than <schema> itself This group is for the elements which occur freely at the top level of schemas. All of their types are based on the "annotated" type by extension. This group is for the elements which can self-redefine (see <redefine> below). A utility type, not for public use A utility type, not for public use A utility type, not for public use #all or (possibly empty) subset of {extension, restriction} A utility type, not for public use A utility type, not for public use #all or (possibly empty) subset of {extension, restriction, list, union} for maxOccurs for all particles for element, group and attributeGroup, which both define and reference 'complexType' uses this This branch is short for <complexContent> <restriction base="xs:anyType"> ... </restriction> </complexContent> Will be restricted to required or forbidden Not allowed if simpleContent child is chosen. May be overriden by setting on complexContent child. This choice is added simply to make this a valid restriction per the REC Overrides any setting on complexType parent. This choice is added simply to make this a valid restriction per the REC No typeDefParticle group reference A utility type, not for public use #all or (possibly empty) subset of {substitution, extension, restriction} The element element can be used either at the top level to define an element-type binding globally, or within a content model to either reference a globally-defined element or type or declare an element-type binding locally. The ref form is not allowed at the top level. group type for explicit groups, named top-level groups and group references group type for the three kinds of group This choice with min/max is here to avoid a pblm with the Elt:All/Choice/Seq Particle derivation constraint restricted max/min Only elements allowed inside simple type for the value of the 'namespace' attr of 'any' and 'anyAttribute' Value is ##any - - any non-conflicting WFXML/attribute at all ##other - - any non-conflicting WFXML/attribute from namespace other than targetNS ##local - - any unqualified non-conflicting WFXML/attribute one or - - any non-conflicting WFXML/attribute from more URI the listed namespaces references (space separated) ##targetNamespace or ##local may appear in the above list, to refer to the targetNamespace of the enclosing schema or an absent targetNamespace respectively A utility type, not for public use A subset of XPath expressions for use in selectors A utility type, not for public use The following pattern is intended to allow XPath expressions per the following EBNF: Selector ::= Path ( '|' Path )* Path ::= ('.//')? Step ( '/' Step )* Step ::= '.' | NameTest NameTest ::= QName | '*' | NCName ':' '*' child:: is also allowed A subset of XPath expressions for use in fields A utility type, not for public use The following pattern is intended to allow XPath expressions per the same EBNF as for selector, with the following change: Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest ) The three kinds of identity constraints, all with type of or derived from 'keybase'. A utility type, not for public use A public identifier, per ISO 8879 notations for use within XML Schema schemas Not the real urType, but as close an approximation as we can get in the XML representation First the built-in primitive datatypes. These definitions are for information only, the real built-in definitions are magic. For each built-in datatype in this schema (both primitive and derived) can be uniquely addressed via a URI constructed as follows: 1) the base URI is the URI of the XML Schema namespace 2) the fragment identifier is the name of the datatype For example, to address the int datatype, the URI is: http://www.w3.org/2001/XMLSchema#int Additionally, each facet definition element can be uniquely addressed via a URI constructed as follows: 1) the base URI is the URI of the XML Schema namespace 2) the fragment identifier is the name of the facet For example, to address the maxInclusive facet, the URI is: http://www.w3.org/2001/XMLSchema#maxInclusive Additionally, each facet usage in a built-in datatype definition can be uniquely addressed via a URI constructed as follows: 1) the base URI is the URI of the XML Schema namespace 2) the fragment identifier is the name of the datatype, followed by a period (".") followed by the name of the facet For example, to address the usage of the maxInclusive facet in the definition of int, the URI is: http://www.w3.org/2001/XMLSchema#int.maxInclusive NOTATION cannot be used directly in a schema; rather a type must be derived from it by specifying at least one enumeration facet whose value is the name of a NOTATION declared in the schema. Now the derived primitive types pattern specifies the content of section 2.12 of XML 1.0e2 and RFC 3066 (Revised version of RFC 1766). pattern matches production 7 from the XML spec pattern matches production 5 from the XML spec pattern matches production 4 from the Namespaces in XML spec A utility type, not for public use #all or (possibly empty) subset of {restriction, union, list} A utility type, not for public use Can be restricted to required or forbidden Required at the top level Forbidden when nested We should use a substitution group for facets, but that's ruled out because it would allow users to add their own, which we're not ready for yet. base attribute and simpleType child are mutually exclusive, but one or other is required itemType attribute and simpleType child are mutually exclusive, but one or other is required memberTypes attribute must be non-empty or there must be at least one simpleType child ================================================ FILE: soap-builder/src/main/resources/xsds/soapEncoding.xsd ================================================ 'root' can be used to distinguish serialization roots from other elements that are present in a serialization but are not roots of a serialized value graph Attributes common to all elements that function as accessors or represent independent (multi-ref) values. The href attribute is intended to be used in a manner like CONREF. That is, the element content should be empty iff the href attribute appears 'Array' is a complex type for accessors identified by position ================================================ FILE: soap-builder/src/main/resources/xsds/soapEncoding12.xsd ================================================ Attributes common to all elements that function as accessors or represent independent (multi-ref) values. The ref attribute is intended to be used in a manner like CONREF. That is, the element content should be empty iff the ref attribute appears A list type that allows * and non negative integers. Used as the base type for arraySize below. Pattern based restriction of the arraySizeBase list type. Used as the type of the arraySize attribute. Restricts asterisk ( * ) to first list item only. Instances must contain at least an asterisk ( * ) or a nonNegativeInteger. May contain other nonNegativeIntegers as subsequent list items. Valid instances include; * 1 * 2 2 2 * 2 0 ================================================ FILE: soap-builder/src/main/resources/xsds/soapEnvelope.xsd ================================================ Prose in the spec does not specify that attributes are allowed on the Body element 'encodingStyle' indicates any canonicalization conventions followed in the contents of the containing element. For example, the value 'http://schemas.xmlsoap.org/soap/encoding/' indicates the pattern described in SOAP specification Fault reporting structure ================================================ FILE: soap-builder/src/main/resources/xsds/soapEnvelope12.xsd ================================================ Elements replacing the wildcard MUST be namespace qualified, but can be in the targetNamespace Fault reporting structure ================================================ FILE: soap-builder/src/main/resources/xsds/swaref.xsd ================================================ ================================================ FILE: soap-builder/src/main/resources/xsds/xmime200411.xsd ================================================ ================================================ FILE: soap-builder/src/main/resources/xsds/xmime200505.xsd ================================================ ================================================ FILE: soap-builder/src/main/resources/xsds/xml.xsd ================================================ See http://www.w3.org/XML/1998/namespace.html and http://www.w3.org/TR/REC-xml for information about this namespace. This schema document describes the XML namespace, in a form suitable for import by other schema documents. Note that local names in this namespace are intended to be defined only by the World Wide Web Consortium or its subgroups. The following names are currently defined in this namespace and should not be used with conflicting semantics by any Working Group, specification, or document instance: base (as an attribute name): denotes an attribute whose value provides a URI to be used as the base for interpreting any relative URIs in the scope of the element on which it appears; its value is inherited. This name is reserved by virtue of its definition in the XML Base specification. id (as an attribute name): denotes an attribute whose value should be interpreted as if declared to be of type ID. The xml:id specification is not yet a W3C Recommendation, but this attribute is included here to facilitate experimentation with the mechanisms it proposes. Note that it is _not_ included in the specialAttrs attribute group. lang (as an attribute name): denotes an attribute whose value is a language code for the natural language of the content of any element; its value is inherited. This name is reserved by virtue of its definition in the XML specification. space (as an attribute name): denotes an attribute whose value is a keyword indicating what whitespace processing discipline is intended for the content of the element; its value is inherited. This name is reserved by virtue of its definition in the XML specification. Father (in any context at all): denotes Jon Bosak, the chair of the original XML Working Group. This name is reserved by the following decision of the W3C XML Plenary and XML Coordination groups: In appreciation for his vision, leadership and dedication the W3C XML Plenary on this 10th day of February, 2000 reserves for Jon Bosak in perpetuity the XML name xml:Father This schema defines attributes and an attribute group suitable for use by schemas wishing to allow xml:base, xml:lang, xml:space or xml:id attributes on elements they define. To enable this, such a schema must import this schema for the XML namespace, e.g. as follows: <schema . . .> . . . <import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/> Subsequently, qualified reference to any of the attributes or the group defined below will have the desired effect, e.g. <type . . .> . . . <attributeGroup ref="xml:specialAttrs"/> will define a type which will schema-validate an instance element with any of those attributes In keeping with the XML Schema WG's standard versioning policy, this schema document will persist at http://www.w3.org/2005/08/xml.xsd. At the date of issue it can also be found at http://www.w3.org/2001/xml.xsd. The schema document at that URI may however change in the future, in order to remain compatible with the latest version of XML Schema itself, or with the XML namespace itself. In other words, if the XML Schema or XML namespaces change, the version of this document at http://www.w3.org/2001/xml.xsd will change accordingly; the version at http://www.w3.org/2005/08/xml.xsd will not change. Attempting to install the relevant ISO 2- and 3-letter codes as the enumerated possible values is probably never going to be a realistic possibility. See RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry at http://www.iana.org/assignments/lang-tag-apps.htm for further information. The union allows for the 'un-declaration' of xml:lang with the empty string. See http://www.w3.org/TR/xmlbase/ for information about this attribute. See http://www.w3.org/TR/xml-id/ for information about this attribute. ================================================ FILE: soap-builder/src/main/resources/xsds/xop.xsd ================================================ ================================================ FILE: soap-builder/src/test/java/org/reficio/ws/builder/DefinitionSaveTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.junit.Test; import org.reficio.ws.builder.core.Wsdl; import javax.wsdl.WSDLException; import java.io.File; import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; /** * User: Tom Bujok (tom.bujok@gmail.com) * Date: 23/05/12 * Time: 11:06 AM */ public class DefinitionSaveTest { public static File getServiceFolder(int serviceId) { URL definitionUrl = ServiceComplianceTest.getDefinitionUrl(serviceId); File definitionFile = new File(definitionUrl.getFile()); File serviceFolder = new File(definitionUrl.getFile()).getParentFile(); if (serviceFolder.exists() == false) { throw new RuntimeException("Cannot get service folder for service " + serviceId); } return serviceFolder; } public static File createTempFolder(String name) throws IOException { File tempFolder = File.createTempFile(name, Long.toString(System.nanoTime())); if (!tempFolder.delete()) { throw new RuntimeException("cannot delete tmp file"); } if (!tempFolder.mkdir()) { throw new RuntimeException("cannot create tmp folder"); } return tempFolder; } public static File getGeneratedFolder(int serviceId) throws WSDLException, IOException { URL wsdlUrl = ServiceComplianceTest.getDefinitionUrl(serviceId); File tempFolder = File.createTempFile("maven-temp", Long.toString(System.nanoTime())); if (!tempFolder.delete()) { throw new RuntimeException("cannot delete tmp file"); } if (!tempFolder.mkdir()) { throw new RuntimeException("cannot create tmp folder"); } String fileName = FilenameUtils.getBaseName(wsdlUrl.toString()); File rootWsdl = new File(tempFolder, fileName); Wsdl.saveWsdl(wsdlUrl, rootWsdl); // builder.saveWsdl(fileName, tempFolder); tempFolder.deleteOnExit(); return tempFolder; } public static List getFileNames(File folder) { final boolean RECURSIVE = true; String[] extensions = new String[]{"wsdl", "xsd"}; Collection files = FileUtils.listFiles(folder, extensions, RECURSIVE); List fileNames = new ArrayList(); for (File file : files) { fileNames.add(file.getName()); } return fileNames; } public static File findFile(File folder, String name) { final boolean RECURSIVE = true; String[] extensions = new String[]{FilenameUtils.getExtension(name)}; Collection files = FileUtils.listFiles(folder, extensions, RECURSIVE); if (files.isEmpty() == false) { return files.iterator().next(); } throw new RuntimeException("File not found " + name); } public static void testDefinitionSave(int serviceId) { try { File serviceFolder = getServiceFolder(serviceId); File generatedFolder = getGeneratedFolder(serviceId); List serviceFileNames = getFileNames(serviceFolder); List generatedFileNames = getFileNames(generatedFolder); Collections.sort(serviceFileNames); Collections.sort(generatedFileNames); assertEquals("serviceId " + serviceId, serviceFileNames.size(), generatedFileNames.size()); for (int i = 0; i < serviceFileNames.size(); i++) { String srvFileName = serviceFileNames.get(i); String genFileName = null; for (int j = 0; j < generatedFileNames.size(); j++) { String tmp = generatedFileNames.get(j); if (tmp.endsWith(srvFileName) || tmp.equals(srvFileName)) { genFileName = generatedFileNames.get(j); break; } } assertNotNull("serviceId " + serviceId + " " + srvFileName + " vs. " + genFileName, genFileName); // TODO - XMLs are not identical due to different import/includes paths // String srvContent = FileUtils.readFileToString(findFile(serviceFolder, srvFileName)); // String genContent = FileUtils.readFileToString(findFile(generatedFolder, genFileName)); // assertTrue("serviceId " + serviceId + " " + srvFileName + " vs. " + genFileName, // XMLUnit.compareXML(srvContent, genContent).identical()); } } catch (Exception e) { throw new RuntimeException("serviceId " + serviceId, e); } } @Test public void testDefinitionSaveService() { for (int serviceId = 1; serviceId <= 18; serviceId++) { testDefinitionSave(serviceId); } } } ================================================ FILE: soap-builder/src/test/java/org/reficio/ws/builder/MessageComplianceTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder; import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; import org.junit.Test; import org.reficio.ws.SoapContext; import org.reficio.ws.common.ResourceUtils; import org.reficio.ws.legacy.SoapLegacyFacade; import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; import static org.junit.Assert.assertEquals; /** * User: Tom Bujok (tom.bujok@gmail.com) * Date: 17/10/11 * Time: Soap11:06 AM */ public class MessageComplianceTest { private final static Logger log = Logger.getLogger(MessageComplianceTest.class); public static String getContent(String folderPath, String fileName) { URL fileUrl = ResourceUtils.getResourceWithAbsolutePackagePath(folderPath, fileName); File file = null; try { file = new File(fileUrl.toURI()); } catch (URISyntaxException e) { file = new File(fileUrl.getPath()); } try { return FileUtils.readFileToString(file).trim(); } catch (IOException e) { throw new RuntimeException(e); } } private static SoapContext context = SoapContext.builder() .exampleContent(false) .typeComments(false) .alwaysBuildHeaders(false) .valueComments(false) .buildOptional(true) .build(); @Test public void testEmptyFaultSoap11() { String emptyFaultSoap11 = SoapLegacyFacade.buildEmptyFault(SoapLegacyFacade.Soap.SOAP_1_1, context); log.info("\n" + emptyFaultSoap11); String expectedMsg = getContent("messages", "EmptyFault11.xml"); assertEquals(expectedMsg, emptyFaultSoap11); } @Test public void testEmptyFaultSoap12() { String emptyFaultSoap12 = SoapLegacyFacade.buildEmptyFault(SoapLegacyFacade.Soap.SOAP_1_2, context); log.info("\n" + emptyFaultSoap12); String expectedMsg = getContent("messages", "EmptyFault12.xml"); assertEquals(expectedMsg, emptyFaultSoap12); } @Test public void testFaultSoap11() { String faultSoap11 = SoapLegacyFacade.buildFault(SoapLegacyFacade.Soap.SOAP_1_1, "VersionMismatch", "Fault Message", context); log.info("\n" + faultSoap11); String expectedMsg = getContent("messages", "FaultVersionMismatch11.xml"); assertEquals(expectedMsg, faultSoap11); } @Test public void testFaultSoap12() { String faultSoap12 = SoapLegacyFacade.buildFault(SoapLegacyFacade.Soap.SOAP_1_2, "VersionMismatch", "Fault Message", context); log.info("\n" + faultSoap12); String expectedMsg = getContent("messages", "FaultVersionMismatch12.xml"); assertEquals(expectedMsg, faultSoap12); } @Test public void testEmptyMessageSoap11() { String emptyMessageSoap11 = SoapLegacyFacade.buildEmptyMessage(SoapLegacyFacade.Soap.SOAP_1_1, context); log.info("\n" + emptyMessageSoap11); String expectedMsg = getContent("messages", "EmptyMessage11.xml"); assertEquals(expectedMsg, emptyMessageSoap11); } @Test public void testEmptyMessageSoap12() { String emptyMessageSoap12 = SoapLegacyFacade.buildEmptyMessage(SoapLegacyFacade.Soap.SOAP_1_2, context); log.info("\n" + emptyMessageSoap12); String expectedMsg = getContent("messages", "EmptyMessage12.xml"); assertEquals(expectedMsg, emptyMessageSoap12); } } ================================================ FILE: soap-builder/src/test/java/org/reficio/ws/builder/ServiceComplianceTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder; import com.ibm.wsdl.xml.WSDLReaderImpl; import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; import org.custommonkey.xmlunit.XMLUnit; import org.junit.Test; import org.reficio.ws.SoapContext; import org.reficio.ws.builder.core.Wsdl; import org.reficio.ws.common.ResourceUtils; import org.reficio.ws.common.XmlUtils; import javax.wsdl.Definition; import javax.wsdl.WSDLException; import javax.wsdl.xml.WSDLReader; import javax.xml.namespace.QName; import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; import static junit.framework.Assert.assertTrue; /** * User: Tom Bujok (tom.bujok@gmail.com) * Date: 12/10/11 * Time: 12:23 PM */ public class ServiceComplianceTest { private final static Logger log = Logger.getLogger(ServiceComplianceTest.class); enum MessageType {REQUEST, RESPONSE} public static String getTestServiceFolderPath(int testServiceId) { String testServiceIdString = (testServiceId < 10) ? "0" + testServiceId : "" + testServiceId; return "/services/test" + testServiceIdString; } public static URL getDefinitionUrl(int testServiceId) { URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath( getTestServiceFolderPath(testServiceId), "TestService.wsdl"); return wsdlUrl; } public static Definition getDefinition(URL wsdlUrl) throws WSDLException { WSDLReader reader = new WSDLReaderImpl(); Definition definition = reader.readWSDL(wsdlUrl.getPath()); return definition; } public static String getExpectedMessage(int testServiceId, String bindingName, String operationName, MessageType msg) { String serviceFolderPath = getTestServiceFolderPath(testServiceId); String messageFolderPath = String.format("%s/operations/%s", serviceFolderPath, bindingName); String fileName = operationName + "." + (MessageType.REQUEST.equals(msg) ? "request" : "response") + ".xml"; URL fileUrl = ResourceUtils.getResourceWithAbsolutePackagePath(messageFolderPath, fileName); File file = null; try { file = new File(fileUrl.toURI()); } catch (URISyntaxException e) { file = new File(fileUrl.getPath()); } try { return FileUtils.readFileToString(file); } catch (IOException e) { throw new RuntimeException(e); } } public static String getExpectedRequest(int testServiceId, String bindingName, String operationName) { return getExpectedMessage(testServiceId, bindingName, operationName, MessageType.REQUEST); } public static String getExpectedResponse(int testServiceId, String bindingName, String operationName) { return getExpectedMessage(testServiceId, bindingName, operationName, MessageType.RESPONSE); } @SuppressWarnings("unchecked") private static void testService(int testServiceId) throws Exception { URL wsdlUrl = getDefinitionUrl(testServiceId); Wsdl parser = Wsdl.parse(wsdlUrl); SoapContext context = SoapContext.builder() .exampleContent(false) .build(); for (QName bindingQName : parser.getBindings()) { String bindingName = bindingQName.getLocalPart(); SoapBuilder builder = parser.binding().name(bindingQName).find(); for (SoapOperation operation : builder.getOperations()) { String request = builder.buildInputMessage(operation); String expectedRequest = getExpectedRequest(testServiceId, bindingName, operation.getOperationName()); log.info(String.format("Comparing binding=[%s] operation=[%s]", bindingName, operation.getOperationName())); log.info("REQUEST:\n" + request); log.info("EXPECTED_REQUEST:\n" + expectedRequest); request = XmlUtils.normalizeAndRemoveValues(request); expectedRequest = XmlUtils.normalizeAndRemoveValues(expectedRequest); log.info("REQUEST_NO_VALUES:\n" + request); log.info("EXPECTED_REQUEST_NO_VALUES:\n" + expectedRequest); assertTrue(XMLUnit.compareXML(expectedRequest, request).identical()); String response = builder.buildOutputMessage(operation, context); String expectedResponse = getExpectedResponse(testServiceId, bindingName, operation.getOperationName()); log.info("RESPONSE:\n" + response); log.info("EXPECTED_RESPONSE:\n" + expectedResponse); response = XmlUtils.normalizeAndRemoveValues(response); expectedResponse = XmlUtils.normalizeAndRemoveValues(expectedResponse); log.info("RESPONSE_NO_VALUES:\n" + response); log.info("EXPECTED_RESPONSE_NO_VALUES:\n" + expectedResponse); assertTrue(XMLUnit.compareXML(expectedResponse, response).identical()); } } } @Test public void testService01() throws Exception { testService(1); } @Test public void testService02() throws Exception { testService(2); } @Test public void testService03() throws Exception { testService(3); } @Test public void testService04() throws Exception { testService(4); } @Test public void testService05() throws Exception { testService(5); } @Test public void testService06() throws Exception { testService(6); } @Test public void testService07() throws Exception { testService(7); } @Test public void testService08() throws Exception { testService(8); } @Test public void testService09() throws Exception { testService(9); } @Test public void testService10() throws Exception { testService(10); } @Test public void testService11() throws Exception { testService(11); } @Test public void testService12() throws Exception { testService(12); } @Test public void testService13() throws Exception { testService(13); } @Test public void testService14() throws Exception { testService(14); } @Test public void testService15() throws Exception { testService(15); } @Test public void testService16() throws Exception { testService(16); } @Test public void testService17() throws Exception { testService(17); } @Test public void testService18() throws Exception { testService(18); } } ================================================ FILE: soap-builder/src/test/java/org/reficio/ws/builder/SoapBuilderImplTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder; import org.junit.Test; import org.reficio.ws.builder.core.Wsdl; import org.reficio.ws.common.ResourceUtils; import javax.wsdl.WSDLException; import java.net.URL; import static junit.framework.Assert.assertNotNull; public class SoapBuilderImplTest { @Test public void testLoadSnowboard_Bug_851() throws WSDLException { URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath("builder", "snowboard.wsdl"); SoapBuilder builder = Wsdl.parse(wsdlUrl).binding().name("{http://namespaces.snowboard-info.com}EndorsementSearchSoapBinding").find(); for (SoapOperation op : builder.getOperations()) { assertNotNull(op); } } } ================================================ FILE: soap-builder/src/test/java/org/reficio/ws/builder/SoapOperationFinderImplTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder; import org.junit.Test; import org.reficio.ws.SoapBuilderException; import org.reficio.ws.builder.core.Wsdl; import org.reficio.ws.common.ResourceUtils; import java.net.URL; import static org.junit.Assert.assertNotNull; public class SoapOperationFinderImplTest { public SoapOperationFinder operation() { URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath("wsdl", "TestService.wsdl"); Wsdl parser = Wsdl.parse(wsdlUrl); String binding = "{http://schemas.eviware.com/TestService/v1/}TestServiceSoap"; return parser.binding().name(binding).find().operation(); } @Test(expected = IllegalArgumentException.class) public void testFinderNoArguments() { operation().find(); } @Test(expected = NullPointerException.class) public void testFinderWrongArgument() { operation().name(null).find(); } @Test(expected = SoapBuilderException.class) public void testFinderNoOperation() { operation().name("asd").find(); } @Test public void testFindOk() { assertNotNull(operation().name("GetDefaultPageData").find()); } @Test(expected = SoapBuilderException.class) public void testFindNameOkWrongAction() { operation().name("GetDefaultPageData").soapAction("asdasdasd").find(); } } ================================================ FILE: soap-builder/src/test/java/org/reficio/ws/builder/WsdlTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.builder; import org.junit.Test; import org.reficio.ws.SoapBuilderException; import org.reficio.ws.SoapContext; import org.reficio.ws.builder.core.Wsdl; import org.reficio.ws.common.ResourceUtils; import javax.xml.namespace.QName; import java.net.MalformedURLException; import java.net.URL; import java.util.List; import static junit.framework.Assert.assertEquals; import static org.junit.Assert.assertNotNull; public class WsdlTest { @Test(expected = NullPointerException.class) public void testParseNullUrl() { Wsdl.parse((String) null); } @Test(expected = SoapBuilderException.class) public void testParseWrongUrl() throws MalformedURLException { URL wsdlUrl = new URL("http://asd.com/asd.wsdl"); Wsdl parser = Wsdl.parse(wsdlUrl); assertNotNull(parser); } @Test public void testParseTestWsdl() { URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath("wsdl", "TestService.wsdl"); Wsdl parser = Wsdl.parse(wsdlUrl); assertNotNull(parser); List bindings = parser.getBindings(); String expectedBindingString = "{http://schemas.eviware.com/TestService/v1/}TestServiceSoap"; QName expectedBinding = QName.valueOf(expectedBindingString); assertEquals(1, bindings.size()); assertEquals(expectedBinding, bindings.iterator().next()); assertNotNull(parser.binding().name(expectedBindingString).find()); assertNotNull(parser.binding().name(expectedBinding).find()); } @Test(expected = NullPointerException.class) public void testParseTestWsdlNullContext() { URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath("wsdl", "TestService.wsdl"); Wsdl parser = Wsdl.parse(wsdlUrl); String expectedBindingString = "{http://schemas.eviware.com/TestService/v1/}TestServiceSoap"; parser.binding().name(expectedBindingString).find(null); } @Test public void testParseTestWsdlProperContext() { URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath("wsdl", "TestService.wsdl"); Wsdl parser = Wsdl.parse(wsdlUrl); String expectedBindingString = "{http://schemas.eviware.com/TestService/v1/}TestServiceSoap"; SoapContext context = SoapContext.builder().typeComments(true).build(); SoapBuilder builder = parser.binding().name(expectedBindingString).find(context); assertEquals(context, builder.getContext()); } } ================================================ FILE: soap-builder/src/test/resources/builder/snowboard.wsdl ================================================ snowboarding-info.com Endorsement Service ================================================ FILE: soap-builder/src/test/resources/log4j.xml ================================================ ================================================ FILE: soap-builder/src/test/resources/messages/EmptyFault11.xml ================================================ ? ? ? ================================================ FILE: soap-builder/src/test/resources/messages/EmptyFault12.xml ================================================ ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/messages/EmptyMessage11.xml ================================================ ================================================ FILE: soap-builder/src/test/resources/messages/EmptyMessage12.xml ================================================ ================================================ FILE: soap-builder/src/test/resources/messages/FaultVersionMismatch11.xml ================================================ VersionMismatch Fault Message ================================================ FILE: soap-builder/src/test/resources/messages/FaultVersionMismatch12.xml ================================================ VersionMismatch Fault Message ================================================ FILE: soap-builder/src/test/resources/services/test01/TestService.wsdl ================================================ Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/Copy.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/Copy.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/Delete.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/Delete.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/DeleteChildren.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/DeleteChildren.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/DeleteVersion.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/DeleteVersion.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/FindPagesWithCriteria.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/FindPagesWithCriteria.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/GetChildren.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/GetChildren.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/GetDefaultPageData.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/GetDefaultPageData.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/GetPage.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/GetPage.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/Move.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/Move.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/Ping.request.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/Ping.response.xml ================================================ ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/Save.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/TestServiceSoap/Save.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test01/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test01/readme.txt ================================================ This setup only uses relative includes ================================================ FILE: soap-builder/src/test/resources/services/test01/testservice1.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test01/testservice2.xsd ================================================

test test

]]>
WorkID is good to h
================================================ FILE: soap-builder/src/test/resources/services/test02/TestService.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/Copy.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/Copy.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/Delete.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/Delete.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/DeleteChildren.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/DeleteChildren.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/DeleteVersion.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/DeleteVersion.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/FindPagesWithCriteria.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/FindPagesWithCriteria.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/GetChildren.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/GetChildren.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/GetDefaultPageData.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/GetDefaultPageData.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/GetPage.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/GetPage.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/Move.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/Move.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/Ping.request.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/Ping.response.xml ================================================ ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/Save.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/TestServiceSoap/Save.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test02/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test02/readme.txt ================================================ This setup uses relative import to xsds, include from xsds ================================================ FILE: soap-builder/src/test/resources/services/test02/testservice1.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test02/testservice2.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test03/TestService.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/Copy.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/Copy.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/Delete.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/Delete.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/DeleteChildren.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/DeleteChildren.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/DeleteVersion.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/DeleteVersion.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/FindPagesWithCriteria.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/FindPagesWithCriteria.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/GetChildren.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/GetChildren.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/GetDefaultPageData.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/GetDefaultPageData.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/GetPage.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/GetPage.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/Move.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/Move.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/Ping.request.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/Ping.response.xml ================================================ ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/Save.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/TestServiceSoap/Save.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test03/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test03/readme.txt ================================================ This setup uses only relative imports ================================================ FILE: soap-builder/src/test/resources/services/test03/testservice1.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test03/testservice2.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test04/TestService.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/Copy.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/Copy.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/Delete.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/Delete.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/DeleteChildren.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/DeleteChildren.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/DeleteVersion.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/DeleteVersion.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/FindPagesWithCriteria.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/FindPagesWithCriteria.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/GetChildren.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/GetChildren.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/GetDefaultPageData.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/GetDefaultPageData.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/GetPage.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/GetPage.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/Move.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/Move.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/Ping.request.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/Ping.response.xml ================================================ ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/Save.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/TestServiceSoap/Save.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test04/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test04/readme.txt ================================================ This setup uses only relative imports and also includes testservice2.xsd into the wsdls types (so it gets included twice) ================================================ FILE: soap-builder/src/test/resources/services/test04/testservice1.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test04/testservice2.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test05/TestBinding.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-builder/src/test/resources/services/test05/TestService.wsdl ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/Copy.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/Copy.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/Delete.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/Delete.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/DeleteChildren.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/DeleteChildren.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/DeleteVersion.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/DeleteVersion.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/FindPagesWithCriteria.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/FindPagesWithCriteria.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/GetChildren.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/GetChildren.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/GetDefaultPageData.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/GetDefaultPageData.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/GetPage.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/GetPage.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/Move.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/Move.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/Ping.request.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/Ping.response.xml ================================================ ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/Save.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/TestServiceSoap/Save.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test05/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test05/readme.txt ================================================ This setup splits the binding and service into 2 files; the later imports the former, which includes the first xsd which imports the second ================================================ FILE: soap-builder/src/test/resources/services/test05/testservice1.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test05/testservice2.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test06/TestService.wsdl ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/Copy.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/Copy.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/Delete.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/Delete.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/DeleteChildren.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/DeleteChildren.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/DeleteVersion.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/DeleteVersion.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/FindPagesWithCriteria.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/FindPagesWithCriteria.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/GetChildren.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/GetChildren.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/GetDefaultPageData.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/GetDefaultPageData.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/GetPage.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/GetPage.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/Move.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/Move.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/Ping.request.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/Ping.response.xml ================================================ ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/Save.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/TestServiceSoap/Save.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test06/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test06/readme.txt ================================================ This setup splits the binding and service into 2 files; the later imports the former, which includes the first xsd which imports the second, now all are in different directories ================================================ FILE: soap-builder/src/test/resources/services/test06/wsdls/TestBinding.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-builder/src/test/resources/services/test06/wsdls/xsds/sub/testservice2.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test06/wsdls/xsds/testservice1.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test07/TestService.wsdl ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/Copy.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/Copy.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/Delete.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/Delete.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/DeleteChildren.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/DeleteChildren.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/DeleteVersion.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/DeleteVersion.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/FindPagesWithCriteria.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/FindPagesWithCriteria.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/GetChildren.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/GetChildren.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/GetDefaultPageData.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/GetDefaultPageData.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/GetPage.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/GetPage.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/Move.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/Move.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/Ping.request.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/Ping.response.xml ================================================ ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/Save.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/TestServiceSoap/Save.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test07/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test07/readme.txt ================================================ This setup splits the binding and service into 2 files; the later imports the former, which includes the first xsd which imports the second, now all are in different directories. This differs from test6 by using an absolut import for the binding wsdl. ================================================ FILE: soap-builder/src/test/resources/services/test07/wsdls/TestBinding.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-builder/src/test/resources/services/test07/wsdls/xsds/sub/testservice2.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test07/wsdls/xsds/testservice1.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test08/TestService.wsdl ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/Copy.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/Copy.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/Delete.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/Delete.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/DeleteChildren.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/DeleteChildren.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/DeleteVersion.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/DeleteVersion.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/FindPagesWithCriteria.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/FindPagesWithCriteria.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/GetChildren.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/GetChildren.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/GetDefaultPageData.request.xml ================================================ ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/GetDefaultPageData.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/GetPage.request.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/GetPage.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/Move.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/Move.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/Ping.request.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/Ping.response.xml ================================================ ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/Save.request.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/TestServiceSoap/Save.response.xml ================================================ ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test08/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test08/readme.txt ================================================ This setup splits the binding and service into 2 files; the later imports the former, which includes the first xsd which imports the second, now all are in different directories. This differs from test7 by using upward relative imports for the second xsd ================================================ FILE: soap-builder/src/test/resources/services/test08/wsdls/TestBinding.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-builder/src/test/resources/services/test08/wsdls/testservice2.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test08/wsdls/xsds/testservice1.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test09/TestService.wsdl ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test09/common.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test09/one.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test09/operations/Binding/Operation.request.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test09/operations/Binding/Operation.response.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test09/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test09/two.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test10/TestService.wsdl ================================================ Read page data from Test Read page data from Test ================================================ FILE: soap-builder/src/test/resources/services/test10/operations/TestServiceSoap/GetDefaultPageData.request.xml ================================================ ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test10/operations/TestServiceSoap/GetDefaultPageData.response.xml ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test10/operations/TestServiceSoap/GetPage.request.xml ================================================ ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test10/operations/TestServiceSoap/GetPage.response.xml ================================================ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test10/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test10/readme.txt ================================================ This setup only uses relative includes onewayop ================================================ FILE: soap-builder/src/test/resources/services/test10/testservice1.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test10/testservice2.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test11/TestService.wsdl ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test11/operations/ADEC_MAST_Binding/doGetSummary.request.xml ================================================ ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test11/operations/ADEC_MAST_Binding/doGetSummary.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test11/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test11/readme.txt ================================================ rpc ================================================ FILE: soap-builder/src/test/resources/services/test12/TestService.wsdl ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test12/operations/IncrementServicePTSOAPBinding/process.request.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test12/operations/IncrementServicePTSOAPBinding/process.response.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test12/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test12/readme.txt ================================================ increment ================================================ FILE: soap-builder/src/test/resources/services/test13/TestService.wsdl ================================================ doc/lit request wrapper for operation "createLink". (Creates a link between two personas.) The id of the first persona. The id of the second persona. doc/lit response wrapper for operation "createLink". (Creates a link between two personas.) The link that was created. Thrown when an attempt is made to do something without the correct permissions. doc/lit request wrapper for operation "createSocialGroup". (Create a social group.) The id of the group leader. The ids of the members of the group. Whether the group is exclusive. doc/lit response wrapper for operation "createSocialGroup". (Create a social group.) The group that was created. doc/lit request wrapper for operation "addToSocialGroup". (Adds a persona to a social group.) The id of the group to add the persona to. The id of the persona to add to the group. doc/lit response wrapper for operation "addToSocialGroup". (Adds a persona to a social group.) Whether the persona was successfully added. Thrown when trying to add someone to a social group that is exclusive. doc/lit request wrapper for operation "readGroups". (Reads the social groups to which a specified persona belongs.) The id of the persona. doc/lit response wrapper for operation "readGroups". (Reads the social groups to which a specified persona belongs.) The social groups that were read. doc/lit request wrapper for operation "readPersona". (Reads a persona.) The id of the persona to read. doc/lit response wrapper for operation "readPersona". (Reads a persona.) The persona. doc/lit request wrapper for operation "readPersonas". (Reads a set of personas.) The ids of the personas. doc/lit response wrapper for operation "readPersonas". (Reads a set of personas.) The personas. doc/lit request wrapper for operation "storePersona". (Store a persona.) Th e persona to store. doc/lit response wrapper for operation "storePersona". (Store a persona.) doc/lit request wrapper for operation "deletePersona". (Delete a persona.) The id of the persona to delete. doc/lit response wrapper for operation "deletePersona". (Delete a persona.) Whether the persona was successfully deleted. request message for operation "createLink". (Creates a link between two personas.) response message for operation "createLink". (Creates a link between two personas.) Thrown when an attempt is made to do something without the correct permissions. request message for operation "createSocialGroup". (Create a social group.) response message for operation "createSocialGroup". (Create a social group.) request message for operation "addToSocialGroup". (Adds a persona to a social group.) response message for operation "addToSocialGroup". (Adds a persona to a social group.) Thrown when trying to add someone to a social group that is exclusive. request message for operation "readGroups". (Reads the social groups to which a specified persona belongs.) response message for operation "readGroups". (Reads the social groups to which a specified persona belongs.) request message for operation "readPersona". (Reads a persona.) response m essage for operation "readPersona". (Reads a persona.) request message for operation "readPersonas". (Reads a set of personas.) response message for operation "readPersonas". (Reads a set of personas.) request message for operation "storePersona". (Store a persona.) response message for operation "storePersona". (Store a persona.) request message for operation "deletePersona". (Delete a persona.) response message for operation "deletePersona". (Delete a persona.) The linkage service is used to service the data for creating links between personas. This includes links and social groups. Creates a link between two personas. Create a social group. Adds a persona to a social group. Reads the social groups to which a specified persona belongs. The persona services is used to perform actions on the data associated with a persona. Reads a persona. Reads a set of personas. Store a persona. Delete a persona. SOAP Binding for LinkageService SOAP Binding for PersonaService ================================================ FILE: soap-builder/src/test/resources/services/test13/chameleon.xsd ================================================ A link between two personas. The id of the first persona. The id of the second persona. A social group. The id of the social group. The ids of the members in the social group. The id of the group leader. Whether the group is exclusive. A name of a persona. ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/LinkageServiceSOAPBinding/addToSocialGroup.request.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/LinkageServiceSOAPBinding/addToSocialGroup.response.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/LinkageServiceSOAPBinding/createLink.request.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/LinkageServiceSOAPBinding/createLink.response.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/LinkageServiceSOAPBinding/createSocialGroup.request.xml ================================================ ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/LinkageServiceSOAPBinding/createSocialGroup.response.xml ================================================ ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/LinkageServiceSOAPBinding/readGroups.request.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/LinkageServiceSOAPBinding/readGroups.response.xml ================================================ ? ? ? ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/PersonaServiceSOAPBinding/deletePersona.request.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/PersonaServiceSOAPBinding/deletePersona.response.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/PersonaServiceSOAPBinding/readPersona.request.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/PersonaServiceSOAPBinding/readPersona.response.xml ================================================ ? ? ? e gero cid:986942279037 ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/PersonaServiceSOAPBinding/readPersonas.request.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/PersonaServiceSOAPBinding/readPersonas.response.xml ================================================ ? ? ? e gero cid:1053368152503 ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/PersonaServiceSOAPBinding/storePersona.request.xml ================================================ ? ? ? e gero cid:111374498880 ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/PersonaServiceSOAPBinding/storePersona.response.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test13/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test13/readme.txt ================================================ chameleon ================================================ FILE: soap-builder/src/test/resources/services/test14/TestService.wsdl ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test14/operations/MakeFriendsSoapBinding/makeFriend.request.xml ================================================ ? ? ================================================ FILE: soap-builder/src/test/resources/services/test14/operations/MakeFriendsSoapBinding/makeFriend.response.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test14/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test15/TestService.wsdl ================================================ My first service ================================================ FILE: soap-builder/src/test/resources/services/test15/operations/StockQuoteSoapBinding/GetLastTradePrice.request.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test15/operations/StockQuoteSoapBinding/GetLastTradePrice.response.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test15/operations/StockQuoteSoapBinding/GetLastTradePrice2.request.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test15/operations/StockQuoteSoapBinding/GetLastTradePrice2.response.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test15/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test15/stockquote-schema.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test16/TestService.wsdl ================================================ Stock service ================================================ FILE: soap-builder/src/test/resources/services/test16/operations/StockQuoteSoapBinding/GetLastTradePrice.request.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test16/operations/StockQuoteSoapBinding/GetLastTradePrice.response.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test16/operations/soap-version.txt ================================================ SOAP 1.1 ================================================ FILE: soap-builder/src/test/resources/services/test16/stockquote-schema.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test17/TestService.wsdl ================================================ My first service ================================================ FILE: soap-builder/src/test/resources/services/test17/operations/StockQuoteSoapBinding/GetLastTradePrice.request.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test17/operations/StockQuoteSoapBinding/GetLastTradePrice.response.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test17/operations/StockQuoteSoapBinding/GetLastTradePrice2.request.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test17/operations/StockQuoteSoapBinding/GetLastTradePrice2.response.xml ================================================ ? ================================================ FILE: soap-builder/src/test/resources/services/test17/operations/soap-version.txt ================================================ SOAP 1.2 ================================================ FILE: soap-builder/src/test/resources/services/test17/stockquote-schema.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test18/TestService.wsdl ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test18/operations/HelloWorldSoap/SayHelloWorld.request.xml ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test18/operations/HelloWorldSoap/SayHelloWorld.response.xml ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test18/operations/HelloWorldSoap12/SayHelloWorld.request.xml ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test18/operations/HelloWorldSoap12/SayHelloWorld.response.xml ================================================ ================================================ FILE: soap-builder/src/test/resources/services/test18/operations/soap-version.txt ================================================ SOAP 1.2 ================================================ FILE: soap-builder/src/test/resources/wsdl/TestService.wsdl ================================================ Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-builder/src/test/resources/wsdl/testservice1.xsd ================================================ ================================================ FILE: soap-builder/src/test/resources/wsdl/testservice2.xsd ================================================

test test

]]>
WorkID is good to h
================================================ FILE: soap-client/pom.xml ================================================ 4.0.0 org.reficio soap-client bundle soap-client - XML based SOAP client org.reficio soap-ws 1.0.0-SNAPSHOT ../pom.xml org.apache.httpcomponents httpclient 4.2.3 org.reficio soap-builder ${project.version} junit junit test log4j log4j commons-logging commons-logging commons-io commons-io commons-codec commons-codec com.googlecode.guava-osgi guava-osgi org.apache.maven.plugins maven-site-plugin 3.1 true ================================================ FILE: soap-client/src/main/java/org/reficio/ws/client/SoapClientException.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.client; import org.reficio.ws.SoapException; /** * Top-level exception type thrown by SoapClient * * @author Tom Bujok * @since 1.0.0 */ public class SoapClientException extends SoapException { public SoapClientException(String message) { super(message); } public SoapClientException(String message, Throwable cause) { super(message, cause); } public SoapClientException(Throwable cause) { super(cause); } } ================================================ FILE: soap-client/src/main/java/org/reficio/ws/client/TransmissionException.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.client; /** * Exception thrown when an transmission error occurs. Returns HTTP error code if returned by the server. * * @author Tom Bujok * @since 1.0.0 */ public class TransmissionException extends SoapClientException { private final String errorResponse; private final Integer errorCode; public TransmissionException(String message) { super(message); this.errorResponse = null; this.errorCode = null; } public TransmissionException(String message, Throwable ex) { super(String.format("%s; %s", message, ex.getMessage()), ex); this.errorResponse = null; this.errorCode = null; } public TransmissionException(String response, Integer errorCode) { super(String.format("HTTP response=[%s] code=[%d]", response, errorCode)); this.errorResponse = response; this.errorCode = errorCode; } public String getErrorResponse() { return errorResponse; } public Integer getErrorCode() { return errorCode; } } ================================================ FILE: soap-client/src/main/java/org/reficio/ws/client/core/Security.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.client.core; import org.reficio.ws.client.SoapClientException; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.security.GeneralSecurityException; import java.security.KeyStore; import static com.google.common.base.Preconditions.checkNotNull; import static org.reficio.ws.client.core.SoapConstants.*; /** * @author: Tom Bujok (tom.bujok@gmail.com) *

* Reficio™ - Reestablish your software! * www.reficio.org */ public class Security { private KeyStore trustStore; private char[] trustStorePassword; private String trustStoreType; private KeyStore keyStore; private char[] keyStorePassword; private String keyStoreType; private String authUsername; private String authPassword; private String authWorkstation; private String authDomain; private String authMethod; private boolean strictHostVerification; private String sslContextProtocol; // ---------------------------------------------------------------- // PUBLIC API // ---------------------------------------------------------------- public KeyStore getTrustStore() { return trustStore; } public char[] getTrustStorePassword() { return trustStorePassword; } public String getTrustStorePasswordAsString() { return trustStorePassword != null ? new String(trustStorePassword) : null; } public String getTrustStoreType() { return trustStoreType; } public KeyStore getKeyStore() { return keyStore; } public char[] getKeyStorePassword() { return keyStorePassword; } public String getKeyStorePasswordAsString() { return keyStorePassword != null ? new String(keyStorePassword) : null; } public String getKeyStoreType() { return keyStoreType; } public String getAuthUsername() { return authUsername; } public String getAuthPassword() { return authPassword; } public String getAuthWorkstation() { return authWorkstation; } public String getAuthDomain() { return authDomain; } public String getAuthMethod() { return authMethod; } public boolean isAuthEnabled() { return !authMethod.equals(AuthMethod.NONE.name()); } public boolean isAuthBasic() { return authMethod.equals(AuthMethod.BASIC.name()); } public boolean isAuthDigest() { return authMethod.equals(AuthMethod.DIGEST.name()); } public boolean isAuthNtlm() { return authMethod.equals(AuthMethod.NTLM.name()); } public boolean isAuthSpnego() { return authMethod.equals(AuthMethod.SPNEGO.name()); } public boolean isStrictHostVerification() { return strictHostVerification; } public String getSslContextProtocol() { return sslContextProtocol; } // ---------------------------------------------------------------- // BUILDER API // ---------------------------------------------------------------- public static Builder builder() { return new Builder(); } private Security() { } /** * Builder to construct a properly populated SoapClient */ public static class Builder { private KeyStore trustStore; private URL trustStoreUrl; private String trustStoreType = JKS_KEYSTORE; private char[] trustStorePassword; private KeyStore keyStore; private URL keyStoreUrl; private String keyStoreType = JKS_KEYSTORE; private char[] keyStorePassword; private String authUsername; private String authPassword; private String authWorkstation; private String authDomain; private String authMethod = AuthMethod.NONE.name(); private String sslContextProtocol = SSL_CONTEXT_PROTOCOL; private Boolean strictHostVerification = false; public Builder authBasic(String user, String password) { authUsername = checkNotNull(user); authPassword = checkNotNull(password); authMethod = AuthMethod.BASIC.name(); return this; } public Builder authDigest(String user, String password) { authUsername = checkNotNull(user); authPassword = checkNotNull(password); authMethod = AuthMethod.DIGEST.name(); return this; } public Builder authNtlm(String user, String password, String workstation, String domain) { authUsername = checkNotNull(user); authPassword = checkNotNull(password); authWorkstation = checkNotNull(workstation); authDomain = checkNotNull(domain); authMethod = AuthMethod.NTLM.name(); return this; } public Builder authSpnego() { authMethod = AuthMethod.SPNEGO.name(); return this; } /** * @param value Specifies the instance of the truststore to use in the SOAP communication. Null is not accepted. * @return builder */ public Builder keyStore(KeyStore value) { checkNotNull(value); keyStore = value; return this; } /** * @param value Specifies the URL of the truststore to use in the SOAP communication. Null is not accepted. * @return builder */ public Builder keyStoreUrl(URL value) { checkNotNull(value); keyStoreUrl = value; return this; } /** * @param value Specifies the URL of the truststore to use in the SOAP communication. Null is not accepted. * @return builder */ public Builder keyStoreUrl(String value) { checkNotNull(value); try { keyStoreUrl = new URL(value); return this; } catch (MalformedURLException ex) { throw new SoapClientException(String.format("URL [%s] is malformed", value), ex); } } /** * @param value Specifies the type of the truststore. Null is not accepted. * @return builder */ public Builder keyStoreType(String value) { checkNotNull(value); keyStoreType = value; return this; } /** * @param value truststore password. Null is accepted. * @return builder */ public Builder keyStorePassword(String value) { if (value != null) { keyStorePassword = value.toCharArray(); } return this; } /** * @param value Specifies the instance of the truststore to use in the SOAP communication. Null is not accepted. * @return builder */ public Builder trustStore(KeyStore value) { checkNotNull(value); trustStore = value; return this; } /** * @param value Specifies the URL of the truststore to use in the SOAP communication. Null is not accepted. * @return builder */ public Builder trustStoreUrl(URL value) { checkNotNull(value); trustStoreUrl = value; return this; } /** * @param value Specifies the URL of the truststore to use in the SOAP communication. Null is not accepted. * @return builder */ public Builder trustStoreUrl(String value) { checkNotNull(value); try { trustStoreUrl = new URL(value); return this; } catch (MalformedURLException ex) { throw new SoapClientException(String.format("URL [%s] is malformed", value), ex); } } /** * @param value Specifies the type of the truststore. Null is not accepted. * @return builder */ public Builder trustStoreType(String value) { checkNotNull(value); trustStoreType = value; return this; } /** * @param value truststore password. Null is accepted. * @return builder */ public Builder trustStorePassword(String value) { if (value != null) { trustStorePassword = value.toCharArray(); } return this; } /** * Enables strict host verification * * @param value strict host verification enables/disabled * @return builder */ public Builder strictHostVerification(boolean value) { strictHostVerification = value; return this; } /** * @param value Specifies the SSL Context Protocol. By default it's SSLv3. Null is not accepted. * @return builder */ public Builder sslContextProtocol(String value) { checkNotNull(value); sslContextProtocol = value; return this; } /** * Constructs properly populated soap client * * @return properly populated soap clients */ public Security build() { Security security = new Security(); security.keyStore = initKeyStore(keyStore, keyStoreUrl, keyStoreType, keyStorePassword); security.keyStoreType = keyStoreType; security.keyStorePassword = keyStorePassword; security.trustStore = initKeyStore(trustStore, trustStoreUrl, trustStoreType, trustStorePassword); security.trustStoreType = trustStoreType; security.trustStorePassword = trustStorePassword; security.sslContextProtocol = sslContextProtocol; security.strictHostVerification = strictHostVerification; security.authUsername = authUsername; security.authPassword = authPassword; security.authWorkstation = authWorkstation; security.authDomain = authDomain; security.authMethod = authMethod; return security; } private KeyStore initKeyStore(KeyStore keyStore, URL keyStoreUrl, String keyStoreType, char[] keyStorePassword) { boolean keyStorePropertiesDefined = keyStoreUrl != null || keyStoreType != null || keyStorePassword != null; if (keyStore != null && keyStorePropertiesDefined) { throw new SoapClientException("Specify either a keyStore | trustStore instance or properties required to load one " + "(url, type, password)"); } if (keyStoreUrl != null) { try { InputStream in = keyStoreUrl.openStream(); KeyStore ks = KeyStore.getInstance(keyStoreType); ks.load(in, keyStorePassword); in.close(); return ks; } catch (GeneralSecurityException e) { throw new SoapClientException("KeyStore setup failed", e); } catch (IOException e) { throw new SoapClientException("KeyStore setup failed", e); } } return null; } } } ================================================ FILE: soap-client/src/main/java/org/reficio/ws/client/core/SecurityFactory.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.client.core; import java.security.KeyStore; import static com.google.common.base.Preconditions.checkNotNull; import static org.reficio.ws.client.core.SoapConstants.AuthMethod; /** * @author: Tom Bujok (tom.bujok@gmail.com) *

* Reficio™ - Reestablish your software! * www.reficio.org */ public class SecurityFactory { private KeyStore trustStore; private String trustStoreUrl; private String trustStorePassword; private String trustStoreType; private KeyStore keyStore; private String keyStoreUrl; private String keyStorePassword; private String keyStoreType; private String authUsername; private String authPassword; private String authWorkstation; private String authDomain; private String authMethod; private Boolean strictHostVerification; private String sslContextProtocol; public KeyStore getTrustStore() { return trustStore; } public void setTrustStore(KeyStore trustStore) { this.trustStore = checkNotNull(trustStore); } public String getTrustStorePassword() { return trustStorePassword; } public void setTrustStorePassword(String trustStorePassword) { this.trustStorePassword = checkNotNull(trustStorePassword); } public String getTrustStoreType() { return trustStoreType; } public void setTrustStoreType(String trustStoreType) { this.trustStoreType = checkNotNull(trustStoreType); } public KeyStore getKeyStore() { return keyStore; } public void setKeyStore(KeyStore keyStore) { this.keyStore = checkNotNull(keyStore); } public String getKeyStorePassword() { return keyStorePassword; } public void setKeyStorePassword(String keyStorePassword) { this.keyStorePassword = checkNotNull(keyStorePassword); } public String getKeyStoreType() { return keyStoreType; } public void setKeyStoreType(String keyStoreType) { this.keyStoreType = checkNotNull(keyStoreType); } public String getAuthUsername() { return authUsername; } public void setAuthUsername(String authUsername) { this.authUsername = checkNotNull(authUsername); } public String getAuthPassword() { return authPassword; } public void setAuthPassword(String authPassword) { this.authPassword = checkNotNull(authPassword); } public String getAuthWorkstation() { return authWorkstation; } public void setAuthWorkstation(String authWorkstation) { this.authWorkstation = checkNotNull(authWorkstation); } public String getAuthDomain() { return authDomain; } public void setAuthDomain(String authDomain) { this.authDomain = checkNotNull(authDomain); } public String getAuthMethod() { return authMethod; } public void setAuthMethod(String authMethod) { this.authMethod = checkNotNull(authMethod).toUpperCase().trim(); } public Boolean getStrictHostVerification() { return strictHostVerification; } public void setStrictHostVerification(Boolean strictHostVerification) { this.strictHostVerification = checkNotNull(strictHostVerification); } public String getSslContextProtocol() { return sslContextProtocol; } public void setSslContextProtocol(String sslContextProtocol) { this.sslContextProtocol = checkNotNull(sslContextProtocol); } public Security create() { Security.Builder builder = Security.builder(); configureKeyStore(builder); configureTrustStore(builder); configureAuthentication(builder); configureTransport(builder); return builder.build(); } private void configureKeyStore(Security.Builder builder) { if (keyStore != null) { builder.keyStore(keyStore); } if (keyStoreUrl != null) { builder.keyStoreUrl(keyStoreUrl); } if (keyStorePassword != null) { builder.keyStorePassword(keyStorePassword); } if (keyStoreType != null) { builder.keyStoreType(keyStoreType); } } private void configureTrustStore(Security.Builder builder) { if (trustStore != null) { builder.trustStore(trustStore); } if (trustStoreUrl != null) { builder.trustStoreUrl(trustStoreUrl); } if (trustStorePassword != null) { builder.trustStorePassword(trustStorePassword); } if (trustStoreType != null) { builder.trustStoreType(trustStoreType); } } private void configureAuthentication(Security.Builder builder) { if(authMethod != null) { AuthMethod method = AuthMethod.valueOf(authMethod); if(method.equals(AuthMethod.BASIC)) { builder.authBasic(authUsername, authPassword); } else if(method.equals(AuthMethod.DIGEST)) { builder.authDigest(authUsername, authPassword); } else if(method.equals(AuthMethod.NTLM)) { builder.authNtlm(authUsername, authPassword, authWorkstation, authDomain); } else if(method.equals(AuthMethod.SPNEGO)) { builder.authSpnego(); } } } private void configureTransport(Security.Builder builder) { if (strictHostVerification != null) { builder.strictHostVerification(strictHostVerification); } if (sslContextProtocol != null) { builder.sslContextProtocol(sslContextProtocol); } } } ================================================ FILE: soap-client/src/main/java/org/reficio/ws/client/core/SoapClient.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.client.core; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.*; import org.apache.http.auth.AuthScope; import org.apache.http.auth.Credentials; import org.apache.http.auth.NTCredentials; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.conn.params.ConnRoutePNames; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.conn.routing.HttpRoutePlanner; import org.apache.http.conn.routing.RouteInfo; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeLayeredSocketFactory; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; import org.apache.http.protocol.HttpContext; import org.apache.http.util.EntityUtils; import org.reficio.ws.SoapException; import org.reficio.ws.annotation.ThreadSafe; import org.reficio.ws.client.SoapClientException; import org.reficio.ws.client.TransmissionException; import org.reficio.ws.client.ssl.SSLUtils; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; import java.security.GeneralSecurityException; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static org.reficio.ws.client.core.SoapConstants.*; /** * SOAP client enables the user to communicate with a SOAP server on a purely XML level. * It supports SSL/TLS, basic-authentication and java.net.Proxy. * When it comes to SOAP it supports version 1.1 and 1.2 - SOAPAction attribute is automatically properly placed, * either in the header (SOAP 1.1) or in the content (SOAP 1.2). * SOAP version recognition is based on the SOAP namespace included in the payload. * This class may throw an unchecked @see org.reficio.ws.client.SoapClientException * * @author Tom Bujok * @since 1.0.0 */ @ThreadSafe public final class SoapClient { private final static Log log = LogFactory.getLog(SoapClient.class); private final static String NULL_SOAP_ACTION = null; private int readTimeoutInMillis; private int connectTimeoutInMillis; private URI endpointUri; private Security endpointProperties; private boolean endpointTlsEnabled; private URI proxyUri; private Security proxyProperties; private boolean proxyTlsEnabled; private DefaultHttpClient client; // ---------------------------------------------------------------- // PUBLIC API // ---------------------------------------------------------------- /** * Post the SOAP message to the SOAP server without specifying the SOAPAction * * @param requestEnvelope SOAP message envelope * @return The result returned by the SOAP server */ public String post(String requestEnvelope) { return post(NULL_SOAP_ACTION, requestEnvelope); } /** * Post the SOAP message to the SOAP server specifying the SOAPAction * * @param soapAction SOAPAction attribute * @param requestEnvelope SOAP message envelope * @return The result returned by the SOAP server */ public String post(String soapAction, String requestEnvelope) { log.debug(String.format("Sending request to host=[%s] action=[%s] request:%n%s", endpointUri.toString(), soapAction, requestEnvelope)); String response = transmit(soapAction, requestEnvelope); log.debug("Received response:\n" + requestEnvelope); return response; } /** * Disconnects from the SOAP server * Underlying connection is a persistent connection by default: * * @link http://docs.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.html */ public void disconnect() { if (client != null) { client.getConnectionManager().shutdown(); } } // ---------------------------------------------------------------- // TRANSMISSION API // ---------------------------------------------------------------- private HttpPost generatePost(String soapAction, String requestEnvelope) { try { HttpPost post = new HttpPost(endpointUri.toString()); StringEntity contentEntity = new StringEntity(requestEnvelope); post.setEntity(contentEntity); if (requestEnvelope.contains(SOAP_1_1_NAMESPACE)) { soapAction = soapAction != null ? "\"" + soapAction + "\"" : ""; post.addHeader(PROP_SOAP_ACTION_11, soapAction); post.addHeader(PROP_CONTENT_TYPE, MIMETYPE_TEXT_XML); client.getParams().setParameter(PROP_CONTENT_TYPE, MIMETYPE_TEXT_XML); } else if (requestEnvelope.contains(SOAP_1_2_NAMESPACE)) { String contentType = MIMETYPE_APPLICATION_XML; if (soapAction != null) { contentType = contentType + PROP_DELIMITER + PROP_SOAP_ACTION_12 + "\"" + soapAction + "\""; } post.addHeader(PROP_CONTENT_TYPE, contentType); } return post; } catch (UnsupportedEncodingException ex) { throw new SoapClientException(ex); } } private String transmit(String soapAction, String data) { HttpPost post = generatePost(soapAction, data); return executePost(post); } private String executePost(HttpPost post) { try { HttpResponse response = client.execute(post); StatusLine statusLine = response.getStatusLine(); HttpEntity entity = response.getEntity(); if (statusLine.getStatusCode() >= 300) { EntityUtils.consume(entity); throw new TransmissionException(statusLine.getReasonPhrase(), statusLine.getStatusCode()); } return entity == null ? null : EntityUtils.toString(entity); } catch (SoapException ex) { throw ex; } catch (ConnectTimeoutException ex) { throw new TransmissionException("Connection timed out", ex); } catch (IOException ex) { throw new TransmissionException("Transmission failed", ex); } catch (RuntimeException ex) { post.abort(); throw new TransmissionException("Transmission aborted", ex); } } // ---------------------------------------------------------------- // INITIALIZATION API // ---------------------------------------------------------------- private void initialize() { configureClient(); configureAuthentication(); configureTls(); configureProxy(); } private void configureClient() { client = new DefaultHttpClient(); HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, connectTimeoutInMillis); HttpConnectionParams.setSoTimeout(httpParameters, readTimeoutInMillis); client.setParams(httpParameters); } private void configureAuthentication() { configureAuthentication(endpointUri, endpointProperties); configureAuthentication(proxyUri, proxyProperties); } private void configureAuthentication(URI uri, Security security) { if (security.isAuthEnabled()) { AuthScope scope = new AuthScope(uri.getHost(), uri.getPort()); Credentials credentials = null; if (security.isAuthBasic()) { credentials = new UsernamePasswordCredentials(security.getAuthUsername(), security.getAuthPassword()); } else if (security.isAuthDigest()) { credentials = new UsernamePasswordCredentials(security.getAuthUsername(), security.getAuthPassword()); } else if (security.isAuthNtlm()) { // TODO credentials = new NTCredentials(security.getAuthUsername(), security.getAuthPassword(), null, null); } else if (security.isAuthSpnego()) { // TODO } client.getCredentialsProvider().setCredentials(scope, credentials); } } private void configureTls() { SSLSocketFactory factory; int port; try { if (endpointTlsEnabled && proxyTlsEnabled) { factory = SSLUtils.getMergedSocketFactory(endpointProperties, proxyProperties); registerTlsScheme(factory, proxyUri.getPort()); } else if (endpointTlsEnabled) { factory = SSLUtils.getFactory(endpointProperties); port = endpointUri.getPort(); registerTlsScheme(factory, port); } else if (proxyTlsEnabled) { factory = SSLUtils.getFactory(proxyProperties); port = proxyUri.getPort(); registerTlsScheme(factory, port); } } catch (GeneralSecurityException ex) { throw new SoapClientException(ex); } } private void registerTlsScheme(SchemeLayeredSocketFactory factory, int port) { Scheme sch = new Scheme(HTTPS, port, factory); client.getConnectionManager().getSchemeRegistry().register(sch); } private void configureProxy() { if (proxyUri == null) { return; } if (proxyTlsEnabled) { final HttpHost proxy = new HttpHost(proxyUri.getHost(), proxyUri.getPort(), HTTPS); // https://issues.apache.org/jira/browse/HTTPCLIENT-1318 // http://stackoverflow.com/questions/15048102/httprouteplanner-how-does-it-work-with-an-https-proxy // To make the HttpClient talk to a HTTP End-site through an HTTPS Proxy, the route should be secure, // but there should not be any Tunnelling or Layering. if (!endpointTlsEnabled) { client.setRoutePlanner(new HttpRoutePlanner() { @Override public HttpRoute determineRoute(HttpHost target, HttpRequest request, HttpContext context) { return new HttpRoute(target, null, proxy, true, RouteInfo.TunnelType.PLAIN, RouteInfo.LayerType.PLAIN); } }); } client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } else { HttpHost proxy = new HttpHost(proxyUri.getHost(), proxyUri.getPort()); client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); } } // ---------------------------------------------------------------- // BUILDER API // ---------------------------------------------------------------- private SoapClient() { } /** * Builder to construct a properly populated SoapClient */ public static class Builder { private Integer readTimeoutInMillis = INFINITE_TIMEOUT; private Integer connectTimeoutInMillis = INFINITE_TIMEOUT; private URI endpointUri; private Security endpointProperties; private boolean endpointTlsEnabled; private URI proxyUri; private Security proxyProperties; private boolean proxyTlsEnabled; /** * @param value URL of the SOAP endpoint to whom the client should send messages. Null is not accepted. * @return builder */ public Builder endpointUri(String value) { checkNotNull(value); try { URI uri = new URI(value); return endpointUri(uri); } catch (URISyntaxException ex) { throw new SoapClientException(String.format("URI [%s] is malformed", value), ex); } } /** * @param value URL of the SOAP endpoint to whom the client should send messages. Null is not accepted. * @return builder */ public Builder endpointUri(URI value) { endpointUri = checkNotNull(value); endpointTlsEnabled = value.getScheme().equalsIgnoreCase(HTTPS); return this; } /** * @param value URL of the SOAP endpoint to whom the client should send messages. Null is not accepted. * @return builder */ public Builder proxyUri(String value) { checkNotNull(value); try { URI uri = new URI(value); return proxyUri(uri); } catch (URISyntaxException ex) { throw new SoapClientException(String.format("URI [%s] is malformed", value), ex); } } /** * @param value URL of the SOAP endpoint to whom the client should send messages. Null is not accepted. * @return builder */ public Builder proxyUri(URI value) { proxyUri = checkNotNull(value); proxyTlsEnabled = value.getScheme().equalsIgnoreCase(HTTPS); return this; } public Builder endpointSecurity(Security value) { this.endpointProperties = checkNotNull(value); return this; } public Builder proxySecurity(Security value) { this.proxyProperties = checkNotNull(value); return this; } /** * @param value Specifies the timeout in millisecond for the read operation. Has to be not negative. * @return builder */ public Builder readTimeoutInMillis(int value) { checkArgument(value >= 0); readTimeoutInMillis = value; return this; } /** * @param value Specifies the timeout in millisecond for the connect operation. Has to be not negative. * @return builder */ public Builder connectTimeoutInMillis(int value) { checkArgument(value >= 0); connectTimeoutInMillis = value; return this; } /** * Constructs properly populated soap client * * @return properly populated soap clients */ public SoapClient build() { return initializeClient(); } private SoapClient initializeClient() { SoapClient client = new SoapClient(); client.endpointUri = endpointUri; if (endpointProperties == null) { endpointProperties = Security.builder().build(); } client.endpointProperties = endpointProperties; client.endpointTlsEnabled = endpointTlsEnabled; client.proxyUri = proxyUri; if (proxyProperties == null) { proxyProperties = Security.builder().build(); } client.proxyProperties = proxyProperties; client.proxyTlsEnabled = proxyTlsEnabled; client.readTimeoutInMillis = readTimeoutInMillis; client.connectTimeoutInMillis = connectTimeoutInMillis; client.initialize(); return client; } } /** * @return a new instance of a SoapClient Builder */ public static Builder builder() { return new Builder(); } } ================================================ FILE: soap-client/src/main/java/org/reficio/ws/client/core/SoapClientFactory.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.client.core; /** * @author Tom Bujok * @since 1.0.0 */ public class SoapClientFactory { private String endpointUri; private Security endpointSecurity; private String proxyUri; private Security proxySecurity; private Integer readTimeoutInMillis; private Integer connectTimeoutInMillis; public String getEndpointUri() { return endpointUri; } public void setEndpointUri(String endpointUri) { this.endpointUri = endpointUri; } public String getProxyUri() { return proxyUri; } public void setProxyUri(String proxyUri) { this.proxyUri = proxyUri; } public Integer getReadTimeoutInMillis() { return readTimeoutInMillis; } public void setReadTimeoutInMillis(Integer readTimeoutInMillis) { this.readTimeoutInMillis = readTimeoutInMillis; } public Integer getConnectTimeoutInMillis() { return connectTimeoutInMillis; } public void setConnectTimeoutInMillis(Integer connectTimeoutInMillis) { this.connectTimeoutInMillis = connectTimeoutInMillis; } public Security getEndpointSecurity() { return endpointSecurity; } public void setEndpointSecurity(Security endpointSecurity) { this.endpointSecurity = endpointSecurity; } public Security getProxySecurity() { return proxySecurity; } public void setProxySecurity(Security proxySecurity) { this.proxySecurity = proxySecurity; } public SoapClient create() { SoapClient.Builder builder = SoapClient.builder(); if (endpointUri != null) { builder.endpointUri(endpointUri); } if (proxyUri != null) { builder.proxyUri(proxyUri); } if (readTimeoutInMillis != null) { builder.readTimeoutInMillis(readTimeoutInMillis); } if (connectTimeoutInMillis != null) { builder.connectTimeoutInMillis(connectTimeoutInMillis); } if (endpointSecurity != null) { builder.endpointSecurity(endpointSecurity); } if (proxySecurity != null) { builder.proxySecurity(proxySecurity); } return builder.build(); } } ================================================ FILE: soap-client/src/main/java/org/reficio/ws/client/core/SoapConstants.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.client.core; /** * @author Tom Bujok * @since 1.0.0 */ final class SoapConstants { private SoapConstants() { } public final static String HTTP = "HTTP", HTTPS = "HTTPS"; public final static String GET = "GET", POST = "POST", HEAD = "HEAD", PUT = "PUT", OPTIONS = "OPTIONS", DELETE = "DELETE"; public final static String MIMETYPE_TEXT_HTML = "text/html", MIMETYPE_TEXT_PLAIN = "text/plain", MIMETYPE_TEXT_XML = "text/xml", MIMETYPE_APPLICATION_XML = "application/soap+xml"; public final static String PROP_SOAP_ACTION_11 = "SOAPAction", PROP_SOAP_ACTION_12 = "action=", PROP_CONTENT_TYPE = "Content-Type", PROP_CONTENT_LENGTH = "Content-Length", PROP_AUTH = "Authorization", PROP_PROXY_AUTH = "Proxy-Authorization", PROP_PROXY_CONN = "Proxy-Connection", PROP_KEEP_ALIVE = "Keep-Alive", PROP_BASIC_AUTH = "Basic", PROP_DELIMITER = "; "; public final static String SOAP_1_1_NAMESPACE = "http://schemas.xmlsoap.org/soap/envelope/", SOAP_1_2_NAMESPACE = "http://www.w3.org/2003/05/soap-envelope"; public final static String SSL_CONTEXT_PROTOCOL = "SSLv3", TLS_CONTEXT = "TLS", JKS_KEYSTORE = "JKS"; public final static int INFINITE_TIMEOUT = 0; public static enum AuthMethod { NONE, BASIC, DIGEST, NTLM, SPNEGO; } } ================================================ FILE: soap-client/src/main/java/org/reficio/ws/client/ssl/MultiX509TrustManager.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.client.ssl; import javax.net.ssl.X509TrustManager; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; /** * @author: Tom Bujok (tom.bujok@gmail.com) *

* Reficio™ - Reestablish your software! * www.reficio.org */ public class MultiX509TrustManager implements X509TrustManager { private final List managers; public MultiX509TrustManager(List managers) { this.managers = new ArrayList(managers); } @Override public void checkClientTrusted(X509Certificate[] x509Certificates, String authType) throws CertificateException { List exceptions = new ArrayList(); try { for (X509TrustManager manager : managers) { manager.checkClientTrusted(x509Certificates, authType); } } catch (CertificateException ex) { exceptions.add(ex); } if (exceptions.size() >= managers.size()) { throw exceptions.iterator().next(); } } @Override public void checkServerTrusted(X509Certificate[] x509Certificates, String authType) throws CertificateException { List exceptions = new ArrayList(); try { for (X509TrustManager manager : managers) { manager.checkServerTrusted(x509Certificates, authType); } } catch (CertificateException ex) { exceptions.add(ex); } if (exceptions.size() >= managers.size()) { throw exceptions.iterator().next(); } } @Override public X509Certificate[] getAcceptedIssuers() { List certs = new ArrayList(); for (X509TrustManager manager : managers) { for (X509Certificate cert : manager.getAcceptedIssuers()) { certs.add(cert); } } return certs.toArray(new X509Certificate[]{}); } } ================================================ FILE: soap-client/src/main/java/org/reficio/ws/client/ssl/SSLUtils.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.client.ssl; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.conn.ssl.X509HostnameVerifier; import org.reficio.ws.client.core.Security; import javax.net.ssl.*; import java.security.*; import java.util.ArrayList; import java.util.List; /** * @author: Tom Bujok (tom.bujok@gmail.com) *

* Reficio™ - Reestablish your software! * www.reficio.org */ public class SSLUtils { public static X509TrustManager getTrustManager(KeyStore trustStore) throws NoSuchAlgorithmException, KeyStoreException { TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(trustStore); return (X509TrustManager) trustManagerFactory.getTrustManagers()[0]; } public static X509KeyManager getKeyManager(KeyStore keyStore, char[] keyStorePassword) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, keyStorePassword); return (X509KeyManager) keyManagerFactory.getKeyManagers()[0]; } public static X509TrustManager getMultiTrustManager(X509TrustManager... managers) { List managersList = new ArrayList(); for (X509TrustManager manager : managers) { managersList.add(manager); } return new MultiX509TrustManager(managersList); } public static SSLSocketFactory getMergedSocketFactory(org.reficio.ws.client.core.Security securityOne, Security securityTwo) throws GeneralSecurityException { X509KeyManager keyManagerOne = getKeyManager(securityOne.getKeyStore(), securityOne.getKeyStorePassword()); X509KeyManager keyManagerTwo = getKeyManager(securityTwo.getKeyStore(), securityTwo.getKeyStorePassword()); X509TrustManager trustManager = getMultiTrustManager( getTrustManager(securityOne.getTrustStore()), getTrustManager(securityTwo.getTrustStore()) ); SSLContext context = SSLContext.getInstance(securityOne.getSslContextProtocol()); boolean strictHostVerification = securityOne.isStrictHostVerification() && securityTwo.isStrictHostVerification(); context.init(new KeyManager[]{keyManagerOne, keyManagerTwo}, new TrustManager[]{trustManager}, new SecureRandom()); X509HostnameVerifier verifier = strictHostVerification ? SSLSocketFactory.STRICT_HOSTNAME_VERIFIER : SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; return new SSLSocketFactory(context, verifier); } public static SSLSocketFactory getFactory(Security security) throws GeneralSecurityException { X509HostnameVerifier verifier = security.isStrictHostVerification() ? SSLSocketFactory.STRICT_HOSTNAME_VERIFIER : SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; SSLSocketFactory socketFactory = new SSLSocketFactory(security.getSslContextProtocol(), security.getKeyStore(), security.getKeyStorePasswordAsString(), security.getTrustStore(), new SecureRandom(), null, verifier); return socketFactory; } } ================================================ FILE: soap-client/src/test/java/org/reficio/ws/client/SimpleClientTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.client; import org.hamcrest.core.AnyOf; import org.hamcrest.core.StringContains; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.reficio.ws.client.core.SoapClient; /** * @author Tom Bujok * @since 1.0.0 */ public class SimpleClientTest { @Rule public ExpectedException exception = ExpectedException.none(); @Ignore @Test(timeout = 10000) public void connectTimeout() { exception.expect(TransmissionException.class); exception.expectMessage(AnyOf.anyOf( StringContains.containsString("failed"), StringContains.containsString("timed out")) ); SoapClient client = SoapClient.builder() .endpointUri("http://test.ch:9999") .connectTimeoutInMillis(1000) .build(); client.post(""); } } ================================================ FILE: soap-client/src/test/resources/log4j.xml ================================================ ================================================ FILE: soap-common/pom.xml ================================================ 4.0.0 org.reficio soap-common org.reficio soap-ws 1.0.0-SNAPSHOT ../pom.xml junit junit 4.9 wsdl4j wsdl4j 1.6.2 com.googlecode.guava-osgi guava-osgi commons-io commons-io org.apache.commons commons-lang3 commons-logging commons-logging xmlunit xmlunit 1.3 ================================================ FILE: soap-common/src/main/java/org/reficio/ws/SoapBuilderException.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws; /** * Default exception thrown by the SoapBuilder. * * @author Tom Bujok * @since 1.0.0 */ public class SoapBuilderException extends SoapException { public SoapBuilderException(String message) { super(message); } public SoapBuilderException(String message, Throwable cause) { super(message, cause); } public SoapBuilderException(Throwable cause) { super(cause.getMessage(), cause); } } ================================================ FILE: soap-common/src/main/java/org/reficio/ws/SoapContext.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws; import javax.xml.namespace.QName; import java.util.HashSet; import java.util.Set; /** * Specifies the context of the SOAP message generation. * * @author Tom Bujok * @since 1.0.0 */ public class SoapContext { public final static SoapContext DEFAULT = SoapContext.builder().build(); public final static SoapContext NO_CONTENT = SoapContext.builder().exampleContent(false).build(); /** * Generates comments with type information in new requests */ private final boolean typeComments; private final boolean valueComments; private final boolean exampleContent; private final boolean buildOptional; private final boolean alwaysBuildHeaders; /* * A list of XML-Schema types and global elements in the form of name@namespace which * will be excluded when generating sample requests and responses and input forms. * By default the XML-Schema root element is added since it is quite common in .NET * services and generates a sample xml fragment of about 300 kb!. */ private final Set excludedTypes; private final SoapMultiValuesProvider multiValuesProvider; /** * Constructor mainly for SpringFramework purposes, in any other case use the fluent builder interface; * #see builder() method * * @param exampleContent * @param typeComments * @param valueComments * @param buildOptional * @param alwaysBuildHeaders * @param excludedTypes */ public SoapContext(boolean exampleContent, boolean typeComments, boolean valueComments, boolean buildOptional, boolean alwaysBuildHeaders, Set excludedTypes, SoapMultiValuesProvider multiValuesProvider) { this.exampleContent = exampleContent; this.typeComments = typeComments; this.valueComments = valueComments; this.buildOptional = buildOptional; this.alwaysBuildHeaders = alwaysBuildHeaders; this.excludedTypes = new HashSet(excludedTypes); this.multiValuesProvider = multiValuesProvider; } /** * Constructor mainly for SpringFramework purposes, in any other case use the fluent builder interface; * #see builder() method * * @param exampleContent * @param typeComments * @param valueComments * @param buildOptional * @param alwaysBuildHeaders */ public SoapContext(boolean exampleContent, boolean typeComments, boolean valueComments, boolean buildOptional, boolean alwaysBuildHeaders) { this.exampleContent = exampleContent; this.typeComments = typeComments; this.valueComments = valueComments; this.buildOptional = buildOptional; this.alwaysBuildHeaders = alwaysBuildHeaders; this.excludedTypes = new HashSet(); this.multiValuesProvider = null; } public boolean isBuildOptional() { return buildOptional; } public boolean isAlwaysBuildHeaders() { return alwaysBuildHeaders; } public boolean isExampleContent() { return exampleContent; } public boolean isTypeComments() { return typeComments; } public boolean isValueComments() { return valueComments; } public Set getExcludedTypes() { return new HashSet(excludedTypes); } public SoapMultiValuesProvider getMultiValuesProvider() { return multiValuesProvider; } public static ContextBuilder builder() { return new ContextBuilder(); } public static class ContextBuilder { private boolean exampleContent = true; private boolean typeComments = false; private boolean valueComments = false; private boolean buildOptional = true; private boolean alwaysBuildHeaders = true; private Set excludedTypes = new HashSet(); private SoapMultiValuesProvider multiValuesProvider = null; /** * Specifies if to generate example SOAP message content * * @param value * @return builder */ public ContextBuilder exampleContent(boolean value) { this.exampleContent = value; return this; } /** * Specifies if to generate SOAP message type comments * * @param value * @return builder */ public ContextBuilder typeComments(boolean value) { this.typeComments = value; return this; } /** * Specifies if to skip SOAP message comments * * @param value * @return builder */ public ContextBuilder valueComments(boolean value) { this.valueComments = value; return this; } /** * Specifies if to generate content for elements marked as optional * * @param value * @return builder */ public ContextBuilder buildOptional(boolean value) { this.buildOptional = value; return this; } /** * Specifies if to always build SOAP headers * * @param value * @return builder */ public ContextBuilder alwaysBuildHeaders(boolean value) { this.alwaysBuildHeaders = value; return this; } /** * A list of XML-Schema types and global elements in the form of name@namespace which * will be excluded when generating sample requests and responses and input forms. * By default the XML-Schema root element is added since it is quite common in .NET * services and generates a sample xml fragment of about 300 kb!. * * @param excludedTypes * @return builder */ public ContextBuilder excludedTypes(Set excludedTypes) { this.excludedTypes = new HashSet(excludedTypes); return this; } public ContextBuilder multiValuesProvider(SoapMultiValuesProvider multiValuesProvider) { this.multiValuesProvider = multiValuesProvider; return this; } /** * Builds populated context instance * * @return fully populated soap context */ public SoapContext build() { return new SoapContext(exampleContent, typeComments, valueComments, buildOptional, alwaysBuildHeaders, excludedTypes, multiValuesProvider); } } } ================================================ FILE: soap-common/src/main/java/org/reficio/ws/SoapException.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws; /** * Top-level exception type thrown by soap-ws * * @author Tom Bujok * @since 1.0.0 */ public class SoapException extends RuntimeException { public SoapException(String s) { super(s); } public SoapException(String s, Throwable throwable) { super(s, throwable); } public SoapException(Throwable throwable) { super(throwable.getMessage(), throwable); } } ================================================ FILE: soap-common/src/main/java/org/reficio/ws/SoapMultiValuesProvider.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws; import javax.xml.namespace.QName; import java.util.Set; /** * @author Tom Bujok * @since 1.0.0 */ public interface SoapMultiValuesProvider { Set getMultiValues(QName name); } ================================================ FILE: soap-common/src/main/java/org/reficio/ws/SoapValidationException.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws; import java.util.ArrayList; import java.util.List; /** * Default exception thrown by the SoapBuilder. * * @author Tom Bujok * @since 1.0.0 */ public class SoapValidationException extends SoapException { private final List errors; public SoapValidationException(List errors) { super("Message validation failed with " + errors.size() + " error(s)\n" + errors); this.errors = errors; } public List getErrors() { return new ArrayList(errors); } } ================================================ FILE: soap-common/src/main/java/org/reficio/ws/annotation/ThreadSafe.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.annotation; import java.lang.annotation.*; /** * @author: Tom Bujok (tom.bujok@gmail.com) *

* Reficio™ - Reestablish your software! * www.reficio.org */ @Documented @Target(value = ElementType.TYPE) @Retention(value = RetentionPolicy.CLASS) public @interface ThreadSafe { } ================================================ FILE: soap-common/src/main/java/org/reficio/ws/common/FileWriter.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.common; import java.io.File; import java.io.IOException; /** * This class was taken from Axis2 code. It's a Wsdl11Writer dependency. * * @author Tom Bujok * @since 1.0.0 */ class FileWriter { /** * Creates/ returns a file object * * @param rootLocation - Location to be written * @param packageName - package, can be '.' separated * @param fileName name of the file * @param extension type of the file, java, cpp etc * @return the File that was created * @throws java.io.IOException * @throws Exception */ public File createClassFile(File rootLocation, String packageName, String fileName, String extension) throws IOException, Exception { File returnFile = null; File root = rootLocation; if (packageName != null) { String directoryNames[] = packageName.split("\\."); File tempFile = null; int length = directoryNames.length; for (int i = 0; i < length; i++) { tempFile = new File(root, directoryNames[i]); root = tempFile; if (!tempFile.exists()) { tempFile.mkdir(); } } } if ((extension != null) && !fileName.endsWith(extension)) { fileName = fileName + extension; } returnFile = new File(root, fileName); if (!returnFile.exists()) { // returnFile.createNewFile(); } return returnFile; } } ================================================ FILE: soap-common/src/main/java/org/reficio/ws/common/ResourceUtils.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.common; import org.apache.commons.io.FilenameUtils; import java.io.InputStream; import java.net.URL; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; /** * Loads resources from the classpath in a relatively seamless way.
* Simplifies the Java API for resource loading. * * @author Tom Bujok * @since 1.0.0 */ public class ResourceUtils { public static URL getResourceWithAbsolutePackagePath(String absolutePackagePath, String resourceName) { return getResourceWithAbsolutePackagePath(ResourceUtils.class, absolutePackagePath, resourceName); } private static class Path { String packagePath = ""; String resourcePath = ""; } private static String getFullPath(String resourcePath) { int linuxIndex = resourcePath.lastIndexOf("/"); int windowsIndex = resourcePath.lastIndexOf("\\"); int index = Math.max(linuxIndex, windowsIndex); if (index < 0) { return ""; } return resourcePath.substring(0, index); } private static Path parsePath(String resourcePath) { checkNotNull(resourcePath, "resourcePath cannot be null"); Path path = new Path(); path.packagePath = getFullPath(resourcePath); path.resourcePath = FilenameUtils.getName(resourcePath); return path; } public static URL getResource(String resourcePath) { Path path = parsePath(resourcePath); return getResourceWithAbsolutePackagePath(path.packagePath, path.resourcePath); } public static URL getResource(Class clazz, String resourcePath) { Path path = parsePath(resourcePath); return getResourceWithAbsolutePackagePath(clazz, path.packagePath, path.resourcePath); } public static InputStream getResourceAsStream(String resourcePath) { Path path = parsePath(resourcePath); return getResourceWithAbsolutePackagePathAsStream(path.packagePath, path.resourcePath); } public static InputStream getResourceAsStream(Class clazz, String resourcePath) { Path path = parsePath(resourcePath); return getResourceWithAbsolutePackagePathAsStream(clazz, path.packagePath, path.resourcePath); } public static URL getResourceWithAbsolutePackagePath(Class clazz, String absolutePackagePath, String resourceName) { checkNotNull(clazz, "clazz cannot be null"); String resourcePath = getResourcePath(absolutePackagePath, resourceName); URL resource = null; // first attempt - outside/inside jar file resource = clazz.getClass().getResource(resourcePath); // second attempt - servlet container - inside application lib folder if (resource == null) { if (resourcePath.charAt(0) == '/') { String resourcePathWithoutLeadingSlash = resourcePath.substring(1); resource = Thread.currentThread().getContextClassLoader().getResource(resourcePathWithoutLeadingSlash); } } checkArgument(resource != null, String.format("Resource [%s] loading failed", resourcePath)); return resource; } public static InputStream getResourceWithAbsolutePackagePathAsStream(String absolutePackagePath, String resourceName) { return getResourceWithAbsolutePackagePathAsStream(ResourceUtils.class, absolutePackagePath, resourceName); } public static InputStream getResourceWithAbsolutePackagePathAsStream(Class clazz, String absolutePackagePath, String resourceName) { checkNotNull(clazz, "clazz cannot be null"); String resourcePath = getResourcePath(absolutePackagePath, resourceName); InputStream resource = null; // first attempt - outside/inside jar file resource = clazz.getClass().getResourceAsStream(resourcePath); // second attempt - servlet container - inside application lib folder if (resource == null) { ClassLoader classLoader = clazz.getClass().getClassLoader(); if (classLoader != null) resource = classLoader.getResourceAsStream(resourcePath); } checkArgument(resource != null, String.format("Resource [%s] loading failed", resourcePath)); return resource; } private static String getResourcePath(String absolutePackagePath, String resourceName) { checkNotNull(absolutePackagePath, "absolutePackagePath cannot be null"); checkNotNull(resourceName, "resourceName cannot be null"); absolutePackagePath = formatArgument(absolutePackagePath); resourceName = formatArgument(resourceName); return constructResourcePath(absolutePackagePath, resourceName); } private static String formatArgument(String argument) { String argumentWithoutWhiteSpaces = argument.trim(); return argumentWithoutWhiteSpaces; } private static String constructResourcePath(String packagePath, String resourceName) { String resourcePath = String.format("/%s/%s", packagePath, resourceName); String resourcePathUnixSeparators = FilenameUtils.separatorsToUnix(resourcePath); String resourcePathNoLeadingSeparators = removeLeadingUnixSeparators(resourcePathUnixSeparators); String normalizedResourcePath = FilenameUtils.normalizeNoEndSeparator(resourcePathNoLeadingSeparators, true); return normalizedResourcePath; } private static String removeLeadingUnixSeparators(String argument) { return argument.replaceAll("/+", "/"); } } ================================================ FILE: soap-common/src/main/java/org/reficio/ws/common/SimpleValuesProvider.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.common; import org.reficio.ws.SoapMultiValuesProvider; import javax.xml.namespace.QName; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; /** * @author Tom Bujok * @since 1.0.0 */ public class SimpleValuesProvider implements SoapMultiValuesProvider { private Map> multiValues; public SimpleValuesProvider() { multiValues = new HashMap>(); } public SimpleValuesProvider(Map> multiValues) { multiValues = new HashMap>(); for (Map.Entry> entry : multiValues.entrySet()) { multiValues.put(entry.getKey(), new HashSet(entry.getValue())); } } @Override public Set getMultiValues(QName name) { Set result = multiValues.get(name); return result != null ? result : new HashSet(); } public void addMultiValues(QName name, Set values) { multiValues.put(name, new HashSet(values)); } } ================================================ FILE: soap-common/src/main/java/org/reficio/ws/common/Wsdl11Writer.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.common; import com.ibm.wsdl.util.xml.DOM2Writer; import org.reficio.ws.SoapException; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import javax.wsdl.Definition; import javax.wsdl.Import; import javax.wsdl.Service; import javax.wsdl.Types; import javax.wsdl.extensions.schema.Schema; import javax.wsdl.extensions.schema.SchemaImport; import javax.wsdl.extensions.schema.SchemaReference; import javax.wsdl.factory.WSDLFactory; import javax.wsdl.xml.WSDLWriter; import java.io.File; import java.io.FileOutputStream; import java.util.*; /** * This class was taken from Axis2 code. It's main responsibility is to marshall wsdl4j Definition instance back into the XML format. * By default it only marshalled the WSDL hierarchy. It was adjusted in such a way that it recursively marshalls XSD schemas as well.

* * @author Tom Bujok * @since 1.0.0 */ public class Wsdl11Writer { public static final String IMPORT_TAG = "import"; public static final String INCLUDE_TAG = "include"; public static final String SCHEMA_LOCATION = "schemaLocation"; private File baseFolder = null; private int count; public Wsdl11Writer(File baseFolder) { this.baseFolder = baseFolder; this.count = 0; } public void writeWSDL(String name, Definition definition) { try { Map baseURIwsdlNameMap = new HashMap(); // add the initial definition to the map baseURIwsdlNameMap.put(definition.getDocumentBaseURI(), name + ".wsdl"); writeWSDL(definition, name + ".wsdl", new HashMap(), baseURIwsdlNameMap); } catch (Exception e) { throw new SoapException("WSDL writing failed!", e); } } @SuppressWarnings("unchecked") private void writeWSDL(Definition definition, String fileName, Map changedMap, Map baseURIwsdlNameMap) throws Exception { // first process the imports and save them. Map imports = definition.getImports(); if (imports != null && (imports.size() > 0)) { Vector importsVector = null; Import wsdlImport = null; String wsdlName = null; String wsdlLocation = null; for (Iterator improtsVectorIter = imports.values().iterator(); improtsVectorIter.hasNext(); ) { importsVector = (Vector) improtsVectorIter.next(); for (Iterator importsIter = importsVector.iterator(); importsIter.hasNext(); ) { wsdlImport = (Import) importsIter.next(); wsdlLocation = wsdlImport.getDefinition().getDocumentBaseURI(); // we have to process this wsdl file only if it has not been processed earlier if (!baseURIwsdlNameMap.containsKey(wsdlLocation)) { wsdlName = wsdlLocation.substring(wsdlLocation.lastIndexOf('/') + 1); if (!wsdlName.endsWith(".wsdl") && !wsdlName.endsWith(".xsd")) { // this seems to be an online wsdl so we generate a dummy name if (wsdlName.indexOf("xsd") > -1) { wsdlName = "xsd" + count++ + ".xsd"; } else { wsdlName = "wsdl" + count++ + ".wsdl"; } } //trim the wsdl part while (baseURIwsdlNameMap.containsValue(wsdlName)) { // import file name can either be xsd or wsdl String fileNamePart = wsdlName.substring(0, wsdlName.lastIndexOf(".")); String extension = wsdlName.substring(wsdlName.lastIndexOf(".")); wsdlName = fileNamePart + count++ + extension; } wsdlName = normalizeName(wsdlName); baseURIwsdlNameMap.put(wsdlLocation, wsdlName); Definition innerDefinition = wsdlImport.getDefinition(); writeWSDL(innerDefinition, wsdlName, changedMap, baseURIwsdlNameMap); } wsdlImport.setLocationURI((String) baseURIwsdlNameMap.get(wsdlLocation)); } } } // change the locations on the imported schemas processSchemas(definition, changedMap); // finally save the file WSDLWriter wsdlWriter = WSDLFactory.newInstance().newWSDLWriter(); // wsdlWriter.setFeature("javax.wsdl.xml.parseXMLSchemas", true); File outputFile = new FileWriter().createClassFile(baseFolder, null, fileName, null); FileOutputStream out = new FileOutputStream(outputFile); // we have a catch here // if there are multimple services in the definition object // we have to write only the relavent service. if (definition.getServices().size() > 1) { List removedServices = new ArrayList(); List servicesList = new ArrayList(); Map services = definition.getServices(); // populate the services list for (Iterator iter = services.values().iterator(); iter.hasNext(); ) { servicesList.add(iter.next()); } Service service; String serviceNameFromFileName = fileName; if (fileName.indexOf(".wsdl") > -1) { serviceNameFromFileName = fileName.substring(0, fileName.lastIndexOf(".wsdl")); } if (fileName.indexOf(".xsd") > -1) { serviceNameFromFileName = fileName.substring(0, fileName.lastIndexOf(".xsd")); } for (Iterator iter = servicesList.iterator(); iter.hasNext(); ) { service = (Service) iter.next(); if (!service.getQName().getLocalPart().equals(serviceNameFromFileName)) { definition.removeService(service.getQName()); removedServices.add(service); } } //now we have only the required service so write it wsdlWriter.writeWSDL(definition, out); // again add the removed services for (Iterator iter = removedServices.iterator(); iter.hasNext(); ) { service = (Service) iter.next(); definition.addService(service); } } else { // no problem proceed normaly wsdlWriter.writeWSDL(definition, out); } out.flush(); out.close(); } /** * adjust the schema locations in the original wsdl * * @param definition * @param changedSchemaLocations */ private void processSchemas(Definition definition, Map changedSchemaLocations) { Types wsdlTypes = definition.getTypes(); if (wsdlTypes != null) { List extensibilityElements = wsdlTypes.getExtensibilityElements(); for (Iterator iter = extensibilityElements.iterator(); iter.hasNext(); ) { Object currentObject = iter.next(); if (currentObject instanceof Schema) { Schema schema = (Schema) currentObject; processSchema(definition, schema, null, changedSchemaLocations); } } } } private void processSchema(Definition definition, Schema schema, String fileName, Map changedSchemaLocations) { try { if (schema.getIncludes() != null) { for (Object o : schema.getIncludes()) { if (o instanceof SchemaReference) { SchemaReference ref = (SchemaReference) o; String fileNameChild = normalizeName(ref.getSchemaLocationURI()); Schema includedSchema = ref.getReferencedSchema(); if (includedSchema == null) { continue; } changedSchemaLocations.put(ref.getSchemaLocationURI(), fileNameChild); processSchema(definition, includedSchema, fileNameChild, changedSchemaLocations); } } } if (schema.getImports() != null && schema.getImports().values() != null) { for (Object o : schema.getImports().values()) { for (Object oi : (Vector) o) { if (oi instanceof SchemaImport) { SchemaImport imp = ((SchemaImport) oi); Schema importedSchema = imp.getReferencedSchema(); if (importedSchema == null) { continue; } String fileNameChild = normalizeName(imp.getSchemaLocationURI()); changedSchemaLocations.put(imp.getSchemaLocationURI(), fileNameChild); processSchema(definition, importedSchema, fileNameChild, changedSchemaLocations); } } } } changeLocations(schema.getElement(), changedSchemaLocations); if (fileName != null) { java.io.FileWriter writer = new java.io.FileWriter(new File(baseFolder, fileName)); DOM2Writer.serializeAsXML(schema.getElement(), definition.getNamespaces(), writer); writer.flush(); writer.close(); } } catch (Exception ex) { throw new SoapException("Unexpected error", ex); } } private void changeLocations(Element element, Map changedSchemaLocations) { NodeList nodeList = element.getChildNodes(); String tagName; for (int i = 0; i < nodeList.getLength(); i++) { tagName = nodeList.item(i).getLocalName(); if (IMPORT_TAG.equals(tagName) || INCLUDE_TAG.equals(tagName)) { processImport(nodeList.item(i), changedSchemaLocations); } } } private void processImport(Node importNode, Map changedSchemaLocations) { NamedNodeMap nodeMap = importNode.getAttributes(); Node attribute; String attributeValue; for (int i = 0; i < nodeMap.getLength(); i++) { attribute = nodeMap.item(i); if (attribute.getNodeName().equals(SCHEMA_LOCATION)) { attributeValue = attribute.getNodeValue(); attributeValue = changedSchemaLocations.get(attributeValue); if (attributeValue != null) { attribute.setNodeValue(attributeValue); } } } } private String normalizeName(String name) { if (name != null) { return name.replaceAll("[^A-Za-z0-9.\\-_]", "_"); } return null; } } ================================================ FILE: soap-common/src/main/java/org/reficio/ws/common/XmlUtils.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.common; import org.custommonkey.xmlunit.XMLUnit; import org.reficio.ws.SoapException; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import java.io.*; import java.util.HashSet; import java.util.Set; /** * @author Tom Bujok * @since 1.0.0 */ public final class XmlUtils { private XmlUtils() { } public static Set getNodeNames(Set nodes) { Set names = new HashSet(); for (Node node : nodes) { names.add(node.getLocalName()); } return names; } public static Set getNodeTypes(Set nodes) { Set names = new HashSet(); for (Node node : nodes) { names.add(nodeToQName(node)); } return names; } public static Set getRootNodes(DOMSource request) { return populateNodes(request.getNode(), new HashSet()); } public static Set populateNodes(Node node, Set nodes) { if (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE) { nodes.add(node); } populateNodes(node.getNextSibling(), nodes); } return nodes; } public static QName nodeToQName(Node node) { return new QName(node.getNamespaceURI(), node.getLocalName()); } public static Source xmlStringToSource(String xmlString) { StringReader reader = new StringReader(xmlString); InputSource src = new InputSource(reader); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder db = dbf.newDocumentBuilder(); Document dom = db.parse(src); Source xmlSource = new javax.xml.transform.dom.DOMSource(dom); return xmlSource; } catch (ParserConfigurationException ex) { throw new SoapException(ex); } catch (SAXException ex) { throw new SoapException(ex); } catch (IOException ex) { throw new SoapException(ex); } } public static String sourceToXmlString(Source xmlSource) { if (xmlSource == null) { return ""; } TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = null; try { transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); StringWriter writer = new StringWriter(); transformer.transform(xmlSource, new StreamResult(writer)); return writer.toString(); } catch (TransformerConfigurationException e) { throw new SoapException("Error during XML transformer configuration", e); } catch (TransformerException e) { throw new SoapException("Error during XML source transformation", e); } } public static String serializePretty(Document document) { try { Writer out = new StringWriter(); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); transformer.transform(new DOMSource(document), new StreamResult(out)); return out.toString(); } catch (TransformerConfigurationException e) { throw new SoapException("Failed to serialize: ", e); } catch (TransformerException e) { throw new SoapException("Failed to serialize: ", e); } } public static String normalizeAndRemoveValues(String xmlContent) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.setCoalescing(true); dbf.setIgnoringElementContentWhitespace(true); dbf.setIgnoringComments(true); DocumentBuilder db = dbf.newDocumentBuilder(); Document document = db.parse(new ByteArrayInputStream(xmlContent.getBytes())); document.normalizeDocument(); processNode(document); return XmlUtils.serializePretty(document); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (SAXException e) { throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } } public static void processNode(Node node) throws Exception { if (node.hasChildNodes()) { for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { processNode(child); } } else { node.setTextContent(" "); } } public static boolean isIdenticalNormalizedWithoutValues(String expected, String current) { String expectedProcessed = normalizeAndRemoveValues(expected); String currentProcessed = normalizeAndRemoveValues(current); try { return XMLUnit.compareXML(expectedProcessed, currentProcessed).identical(); } catch (SAXException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } } ================================================ FILE: soap-common/src/test/java/org/reficio/ws/common/ResourceLoaderTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.common; import org.junit.Assert; import org.junit.Test; import java.io.InputStream; import java.net.URL; public class ResourceLoaderTest { @Test public void loadWithSystemClassloaderTest() { URL url5 = System.class.getResource("/org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(url5); InputStream in = getClass().getResourceAsStream("/org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(in); InputStream in2 = getClass().getClassLoader().getResourceAsStream("org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(in2); URL url = getClass().getResource("/org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(url); URL url2 = getClass().getClassLoader().getResource("org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(url2); InputStream stream = ResourceLoaderTest.class.getResourceAsStream("/org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(stream); InputStream stream2 = ResourceLoaderTest.class.getClassLoader().getResourceAsStream("org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(stream2); URL url3 = ResourceLoaderTest.class.getResource("/org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(url3); URL url4 = ResourceLoaderTest.class.getClassLoader().getResource("org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(url4); } } ================================================ FILE: soap-common/src/test/java/org/reficio/ws/common/ResourceUtilsTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.common; import org.junit.Assert; import org.junit.Test; import java.io.InputStream; import java.net.URL; /** * User: Tom Bujok (tom.bujok@gmail.com) * Date: 11/10/11 * Time: 11:16 AM */ public class ResourceUtilsTest { @Test(expected = IllegalArgumentException.class) public void testResourceLoading_failed() { URL url = ResourceUtils.getResourceWithAbsolutePackagePath(System.class, "org/reficio/ws/common/test", "soapEncoding.xsd123123"); } @Test(expected = IllegalArgumentException.class) public void testResourceLoading_failed_noPackage() { URL url = ResourceUtils.getResource(System.class, "asdasdasdasd.txt"); } @Test public void testResourceLoading_noLeadingTrailing() { URL url = ResourceUtils.getResourceWithAbsolutePackagePath(System.class, "org/reficio/ws/common/test", "soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_noLeadingTrailing_noPackage() { URL url = ResourceUtils.getResource(System.class, "org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_noLeading() { URL url = ResourceUtils.getResourceWithAbsolutePackagePath(System.class, "org/reficio/ws/common/test/", "soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_noLeading_noPackage() { URL url = ResourceUtils.getResource(System.class, "org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_multipleLeading() { URL url = ResourceUtils.getResourceWithAbsolutePackagePath(System.class, "//////org/reficio/ws/common/test/", "soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_multipleLeading_noPackage() { URL url = ResourceUtils.getResource(System.class, "//////org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoadingNoTrailing() { URL url = ResourceUtils.getResourceWithAbsolutePackagePath(System.class, "/org/reficio/ws/common/test", "soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoadingNoTrailing_noPackage() { URL url = ResourceUtils.getResource(System.class, "/org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_whiteSpaces() { URL url = ResourceUtils.getResourceWithAbsolutePackagePath(System.class, " /org/reficio/ws/common/test ", "soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_whiteSpaces_noPackage() { URL url = ResourceUtils.getResource(System.class, " /org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_multipleInner() { URL url = ResourceUtils.getResourceWithAbsolutePackagePath(System.class, "/org///reficio////ws/common/////test", "soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_multipleInner_noPackage() { URL url = ResourceUtils.getResource(System.class, "/org///reficio////ws/common/////test/////soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_multipleTrailing() { URL url = ResourceUtils.getResourceWithAbsolutePackagePath(System.class, "org/reficio/ws/common/test//////", "soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_multipleTrailing_noPackage() { URL url = ResourceUtils.getResource(System.class, "org/reficio/ws/common/test//////soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_notNormalized() { URL url = ResourceUtils.getResourceWithAbsolutePackagePath(System.class, "org/../org/reficio/../reficio/ws/common/test/", "soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_notNormalized_noPackage() { URL url = ResourceUtils.getResource(System.class, "org/../org/reficio/../reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoading_notNormalized_asStream() { InputStream stream = ResourceUtils.getResourceWithAbsolutePackagePathAsStream(System.class, "/org/../org/reficio/../reficio/ws/common/test/", "soapEncoding.xsd"); Assert.assertNotNull(stream); } @Test public void testResourceLoading_notNormalized_asStream_noPackage() { InputStream stream = ResourceUtils.getResourceAsStream(System.class, "/org/../org/reficio/../reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(stream); } @Test public void testResourceLoadingObject() { InputStream stream = ResourceUtils.getResourceWithAbsolutePackagePathAsStream(Object.class, "/org/reficio/ws/common/test/", "soapEncoding.xsd"); Assert.assertNotNull(stream); } @Test public void testResourceLoadingObject_noPackage() { InputStream stream = ResourceUtils.getResourceAsStream(Object.class, "/org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(stream); } @Test public void testResourceLoadingThis() { InputStream stream = ResourceUtils.getResourceWithAbsolutePackagePathAsStream(ResourceUtilsTest.class, "/org/reficio/ws/common/test/", "soapEncoding.xsd"); Assert.assertNotNull(stream); } @Test public void testResourceLoadingThis_noPackage() { InputStream stream = ResourceUtils.getResourceAsStream(ResourceUtilsTest.class, "/org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(stream); } @Test public void testResourceLoadingGetClass() { InputStream stream = ResourceUtils.getResourceWithAbsolutePackagePathAsStream(getClass(), "/org/reficio/ws/common/test/", "soapEncoding.xsd"); Assert.assertNotNull(stream); } @Test public void testResourceLoadingGetClass_noPackage() { InputStream stream = ResourceUtils.getResourceAsStream(getClass(), "/org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(stream); } @Test public void testResourceLoadingNoClass() { InputStream stream = ResourceUtils.getResourceWithAbsolutePackagePathAsStream("/org/reficio/ws/common/test/", "soapEncoding.xsd"); Assert.assertNotNull(stream); } @Test public void testResourceLoadingNoClass_noPackage() { InputStream stream = ResourceUtils.getResourceAsStream("/org/reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(stream); } @Test public void testResourceLoadingNotNormalizedNoClass() { URL url = ResourceUtils.getResourceWithAbsolutePackagePath("org/../org/reficio/../reficio/ws/common/test/", "soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoadingNotNormalizedNoClass_noPackage() { URL url = ResourceUtils.getResource("org/../org/reficio/../reficio/ws/common/test/soapEncoding.xsd"); Assert.assertNotNull(url); } @Test public void testResourceLoadingSpaceInTheResource() { URL url = ResourceUtils.getResourceWithAbsolutePackagePath("my folder", "resource.txt"); Assert.assertNotNull(url); } @Test public void testResourceLoadingSpaceInTheResource_noPackage() { URL url = ResourceUtils.getResource("my folder/resource.txt"); Assert.assertNotNull(url); } } ================================================ FILE: soap-common/src/test/java/org/reficio/ws/common/XmlComparator.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.common; /** * User: Tom Bujok (tom.bujok@gmail.com) * Date: 14/10/11 * Time: 10:31 AM */ import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class XmlComparator { private boolean nodeTypeDiff = true; private boolean nodeValueDiff = true; public boolean diff(String xml1, String xml2, List diffs) throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); dbf.setCoalescing(true); dbf.setIgnoringElementContentWhitespace(true); dbf.setIgnoringComments(true); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc1 = db.parse(new ByteArrayInputStream(xml1.getBytes())); Document doc2 = db.parse(new ByteArrayInputStream(xml2.getBytes())); doc1.normalizeDocument(); doc2.normalizeDocument(); // log.info("\n" + XmlUtils.serializePretty(doc1)); // log.info("\n" + XmlUtils.serializePretty(doc2)); return diff(doc1, doc2, diffs); } /** * Diff 2 nodes and put the diffs in the list */ public boolean diff(Node node1, Node node2, List diffs) throws Exception { if (diffNodeExists(node1, node2, diffs)) { return true; } if (nodeTypeDiff) { diffNodeType(node1, node2, diffs); } if (nodeValueDiff) { diffNodeValue(node1, node2, diffs); } // log.info(node1.getNodeName() + "/" + node2.getNodeName()); diffAttributes(node1, node2, diffs); diffNodes(node1, node2, diffs); return diffs.size() > 0; } /** * Diff the nodes */ public boolean diffNodes(Node node1, Node node2, List diffs) throws Exception { //Sort by Name Map children1 = new LinkedHashMap(); for (Node child1 = node1.getFirstChild(); child1 != null; child1 = child1.getNextSibling()) { children1.put(child1.getNodeName(), child1); } //Sort by Name Map children2 = new LinkedHashMap(); for (Node child2 = node1.getFirstChild(); child2 != null; child2 = child2.getNextSibling()) { children2.put(child2.getNodeName(), child2); } //Diff all the children1 for (Node child1 : children1.values()) { Node child2 = children2.remove(child1.getNodeName()); diff(child1, child2, diffs); } //Diff all the children2 left over for (Node child2 : children2.values()) { Node child1 = children1.get(child2.getNodeName()); diff(child1, child2, diffs); } return diffs.size() > 0; } /** * Diff the nodes */ public boolean diffAttributes(Node node1, Node node2, List diffs) throws Exception { //Sort by Name NamedNodeMap nodeMap1 = node1.getAttributes(); Map attributes1 = new LinkedHashMap(); for (int index = 0; nodeMap1 != null && index < nodeMap1.getLength(); index++) { attributes1.put(nodeMap1.item(index).getNodeName(), nodeMap1.item(index)); } //Sort by Name NamedNodeMap nodeMap2 = node2.getAttributes(); Map attributes2 = new LinkedHashMap(); for (int index = 0; nodeMap2 != null && index < nodeMap2.getLength(); index++) { attributes2.put(nodeMap2.item(index).getNodeName(), nodeMap2.item(index)); } //Diff all the attributes1 for (Node attribute1 : attributes1.values()) { Node attribute2 = attributes2.remove(attribute1.getNodeName()); diff(attribute1, attribute2, diffs); } //Diff all the attributes2 left over for (Node attribute2 : attributes2.values()) { Node attribute1 = attributes1.get(attribute2.getNodeName()); diff(attribute1, attribute2, diffs); } return diffs.size() > 0; } /** * Check that the nodes exist */ public boolean diffNodeExists(Node node1, Node node2, List diffs) throws Exception { if (node1 == null && node2 == null) { diffs.add(getPath(node2) + ":node " + node1 + "!=" + node2 + "\n"); return true; } if (node1 == null && node2 != null) { diffs.add(getPath(node2) + ":node " + node1 + "!=" + node2.getNodeName()); return true; } if (node1 != null && node2 == null) { diffs.add(getPath(node1) + ":node " + node1.getNodeName() + "!=" + node2); return true; } return false; } /** * Diff the Node Type */ public boolean diffNodeType(Node node1, Node node2, List diffs) throws Exception { if (node1.getNodeType() != node2.getNodeType()) { diffs.add(getPath(node1) + ":type " + node1.getNodeType() + "!=" + node2.getNodeType()); return true; } return false; } /** * Diff the Node Value */ public boolean diffNodeValue(Node node1, Node node2, List diffs) throws Exception { if (node1.getNodeValue() == null && node2.getNodeValue() == null) { return false; } if (node1.getNodeValue() == null && node2.getNodeValue() != null) { diffs.add(getPath(node1) + ":type " + node1 + "!=" + node2.getNodeValue()); return true; } if (node1.getNodeValue() != null && node2.getNodeValue() == null) { diffs.add(getPath(node1) + ":type " + node1.getNodeValue() + "!=" + node2); return true; } if (!node1.getNodeValue().equals(node2.getNodeValue())) { diffs.add(getPath(node1) + ":type " + node1.getNodeValue() + "!=" + node2.getNodeValue()); return true; } return false; } /** * Get the node path */ public String getPath(Node node) { StringBuilder path = new StringBuilder(); do { path.insert(0, node.getNodeName()); path.insert(0, "/"); } while ((node = node.getParentNode()) != null); return path.toString(); } } ================================================ FILE: soap-common/src/test/resources/my folder/resource.txt ================================================ ================================================ FILE: soap-common/src/test/resources/org/reficio/ws/common/test/soapEncoding.xsd ================================================ 'root' can be used to distinguish serialization roots from other elements that are present in a serialization but are not roots of a serialized value graph Attributes common to all elements that function as accessors or represent independent (multi-ref) values. The href attribute is intended to be used in a manner like CONREF. That is, the element content should be empty iff the href attribute appears 'Array' is a complex type for accessors identified by position ================================================ FILE: soap-examples/arquillian/pom.xml ================================================ 4.0.0 org.reficio arquillian jar soap-examples - arquillian soap-examples org.reficio 1.0.0-SNAPSHOT org.jboss.spec jboss-javaee-6.0 1.0.0.Final pom provided junit junit test org.jboss.arquillian.junit arquillian-junit-container test org.jboss.arquillian.container arquillian-weld-ee-embedded-1.1 1.0.0.CR3 test org.jboss.weld weld-core 1.1.5.Final test org.slf4j slf4j-simple 1.6.4 test org.reficio soap-builder ${project.version} org.reficio soap-test ${project.version} org.reficio soap-client ${project.version} org.reficio soap-server ${project.version} org.codehaus.groovy groovy-all org.jboss.arquillian arquillian-bom 1.0.3.Final import pom ================================================ FILE: soap-examples/arquillian/src/test/java/org/reficio/ws/arquillian/Greeter.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.arquillian; import groovy.util.XmlSlurper; import org.reficio.ws.builder.core.Wsdl; import org.reficio.ws.client.core.SoapClient; import org.reficio.ws.common.ResourceUtils; import org.xml.sax.helpers.XMLReaderFactory; import java.io.PrintStream; import java.net.URL; /** * @author: Tom Bujok (tom.bujok@gmail.com) *

* Reficio™ - Reestablish your software! * www.reficio.org */ public class Greeter { public String getConversionRate(String fromCurrency, String toCurrency) throws Exception { URL url = ResourceUtils.getResource("wsdl/currency-convertor.wsdl"); // generate the message (the quickest way) String input = Wsdl.parse(url) .binding().name("{http://www.webserviceX.NET/}CurrencyConvertorSoap").find() .operation().soapAction("http://www.webserviceX.NET/ConversionRate").find() .buildInputMessage(); SoapClient client = SoapClient.builder() .endpointUri("http://localhost:51515/service") .build(); String response = client.post(input); XmlSlurper slurper = new XmlSlurper(XMLReaderFactory.createXMLReader()); return slurper.parseText(response).toString(); } public void greet(PrintStream to, String name) { to.println(createGreeting(name)); } public String createGreeting(String name) { return "Hello, " + name + "!"; } } ================================================ FILE: soap-examples/arquillian/src/test/java/org/reficio/ws/arquillian/GreeterTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.arquillian; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.reficio.ws.test.junit.Server; import org.reficio.ws.test.junit.SoapRule; import javax.inject.Inject; /** * @author: Tom Bujok (tom.bujok@gmail.com) *

* Reficio™ - Reestablish your software! * www.reficio.org */ @RunWith(Arquillian.class) public class GreeterTest { @Rule public SoapRule rule = new SoapRule(); @Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addClass(Greeter.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } @Inject Greeter greeter; @Test public void should_create_greeting() { Assert.assertEquals("Hello, Earthling!", greeter.createGreeting("Earthling")); greeter.greet(System.out, "Earthling"); } // @Server annotation spawns an instance of a SoapServer for the lifespan of the test / method. // The SOAP server provides a SOAP auto-responder for the specified binding -> messages are generated and sent automatically. // Generated messages are compliant with the WSDL and the schema (including enumerations, etc.) // The @Server annotation may be also used to annotate a method -> it spawns a SoapServer for the lifespan of the test method. // In order to enable the @Server annotation a junit @Rule has to be defined (JUnit requirement): // - org.junit.ClassRule in order to enable the @Server on a per-class basis // - org.junit.Rule in order to enable the @Server on a per-class basis @Test @Server(wsdl = "classpath:wsdl/currency-convertor.wsdl", binding = "CurrencyConvertorSoap") public void getConversionRateSoapTest() throws Exception { String rate = greeter.getConversionRate("USD", "EUR"); Assert.assertNotNull(rate); Float rateFloat = Float.parseFloat(rate); Assert.assertTrue(rateFloat > 0.75); } } ================================================ FILE: soap-examples/arquillian/src/test/java/org/reficio/ws/arquillian/README.txt ================================================ ==== Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==== http://arquillian.org/guides/getting_started/ ================================================ FILE: soap-examples/arquillian/src/test/resources/log4j.xml ================================================ ================================================ FILE: soap-examples/arquillian/src/test/resources/wsdl/currency-convertor.wsdl ================================================ <br><b>Get conversion rate from one currency to another currency <b><br><p><b><font color='#000080' size='1' face='Verdana'><u>Differenct currency Code and Names around the world</u></font></b></p><blockquote><p><font face='Verdana' size='1'>AFA-Afghanistan Afghani<br>ALL-Albanian Lek<br>DZD-Algerian Dinar<br>ARS-Argentine Peso<br>AWG-Aruba Florin<br>AUD-Australian Dollar<br>BSD-Bahamian Dollar<br>BHD-Bahraini Dinar<br>BDT-Bangladesh Taka<br>BBD-Barbados Dollar<br>BZD-Belize Dollar<br>BMD-Bermuda Dollar<br>BTN-Bhutan Ngultrum<br>BOB-Bolivian Boliviano<br>BWP-Botswana Pula<br>BRL-Brazilian Real<br>GBP-British Pound<br>BND-Brunei Dollar<br>BIF-Burundi Franc<br>XOF-CFA Franc (BCEAO)<br>XAF-CFA Franc (BEAC)<br>KHR-Cambodia Riel<br>CAD-Canadian Dollar<br>CVE-Cape Verde Escudo<br>KYD-Cayman Islands Dollar<br>CLP-Chilean Peso<br>CNY-Chinese Yuan<br>COP-Colombian Peso<br>KMF-Comoros Franc<br>CRC-Costa Rica Colon<br>HRK-Croatian Kuna<br>CUP-Cuban Peso<br>CYP-Cyprus Pound<br>CZK-Czech Koruna<br>DKK-Danish Krone<br>DJF-Dijibouti Franc<br>DOP-Dominican Peso<br>XCD-East Caribbean Dollar<br>EGP-Egyptian Pound<br>SVC-El Salvador Colon<br>EEK-Estonian Kroon<br>ETB-Ethiopian Birr<br>EUR-Euro<br>FKP-Falkland Islands Pound<br>GMD-Gambian Dalasi<br>GHC-Ghanian Cedi<br>GIP-Gibraltar Pound<br>XAU-Gold Ounces<br>GTQ-Guatemala Quetzal<br>GNF-Guinea Franc<br>GYD-Guyana Dollar<br>HTG-Haiti Gourde<br>HNL-Honduras Lempira<br>HKD-Hong Kong Dollar<br>HUF-Hungarian Forint<br>ISK-Iceland Krona<br>INR-Indian Rupee<br>IDR-Indonesian Rupiah<br>IQD-Iraqi Dinar<br>ILS-Israeli Shekel<br>JMD-Jamaican Dollar<br>JPY-Japanese Yen<br>JOD-Jordanian Dinar<br>KZT-Kazakhstan Tenge<br>KES-Kenyan Shilling<br>KRW-Korean Won<br>KWD-Kuwaiti Dinar<br>LAK-Lao Kip<br>LVL-Latvian Lat<br>LBP-Lebanese Pound<br>LSL-Lesotho Loti<br>LRD-Liberian Dollar<br>LYD-Libyan Dinar<br>LTL-Lithuanian Lita<br>MOP-Macau Pataca<br>MKD-Macedonian Denar<br>MGF-Malagasy Franc<br>MWK-Malawi Kwacha<br>MYR-Malaysian Ringgit<br>MVR-Maldives Rufiyaa<br>MTL-Maltese Lira<br>MRO-Mauritania Ougulya<br>MUR-Mauritius Rupee<br>MXN-Mexican Peso<br>MDL-Moldovan Leu<br>MNT-Mongolian Tugrik<br>MAD-Moroccan Dirham<br>MZM-Mozambique Metical<br>MMK-Myanmar Kyat<br>NAD-Namibian Dollar<br>NPR-Nepalese Rupee<br>ANG-Neth Antilles Guilder<br>NZD-New Zealand Dollar<br>NIO-Nicaragua Cordoba<br>NGN-Nigerian Naira<br>KPW-North Korean Won<br>NOK-Norwegian Krone<br>OMR-Omani Rial<br>XPF-Pacific Franc<br>PKR-Pakistani Rupee<br>XPD-Palladium Ounces<br>PAB-Panama Balboa<br>PGK-Papua New Guinea Kina<br>PYG-Paraguayan Guarani<br>PEN-Peruvian Nuevo Sol<br>PHP-Philippine Peso<br>XPT-Platinum Ounces<br>PLN-Polish Zloty<br>QAR-Qatar Rial<br>ROL-Romanian Leu<br>RUB-Russian Rouble<br>WST-Samoa Tala<br>STD-Sao Tome Dobra<br>SAR-Saudi Arabian Riyal<br>SCR-Seychelles Rupee<br>SLL-Sierra Leone Leone<br>XAG-Silver Ounces<br>SGD-Singapore Dollar<br>SKK-Slovak Koruna<br>SIT-Slovenian Tolar<br>SBD-Solomon Islands Dollar<br>SOS-Somali Shilling<br>ZAR-South African Rand<br>LKR-Sri Lanka Rupee<br>SHP-St Helena Pound<br>SDD-Sudanese Dinar<br>SRG-Surinam Guilder<br>SZL-Swaziland Lilageni<br>SEK-Swedish Krona<br>TRY-Turkey Lira<br>CHF-Swiss Franc<br>SYP-Syrian Pound<br>TWD-Taiwan Dollar<br>TZS-Tanzanian Shilling<br>THB-Thai Baht<br>TOP-Tonga Pa'anga<br>TTD-Trinidad&amp;amp;Tobago Dollar<br>TND-Tunisian Dinar<br>TRL-Turkish Lira<br>USD-U.S. Dollar<br>AED-UAE Dirham<br>UGX-Ugandan Shilling<br>UAH-Ukraine Hryvnia<br>UYU-Uruguayan New Peso<br>VUV-Vanuatu Vatu<br>VEB-Venezuelan Bolivar<br>VND-Vietnam Dong<br>YER-Yemen Riyal<br>YUM-Yugoslav Dinar<br>ZMK-Zambian Kwacha<br>ZWD-Zimbabwe Dollar</font></p></blockquote> <br><b>Get conversion rate from one currency to another currency <b><br><p><b><font color='#000080' size='1' face='Verdana'><u>Differenct currency Code and Names around the world</u></font></b></p><blockquote><p><font face='Verdana' size='1'>AFA-Afghanistan Afghani<br>ALL-Albanian Lek<br>DZD-Algerian Dinar<br>ARS-Argentine Peso<br>AWG-Aruba Florin<br>AUD-Australian Dollar<br>BSD-Bahamian Dollar<br>BHD-Bahraini Dinar<br>BDT-Bangladesh Taka<br>BBD-Barbados Dollar<br>BZD-Belize Dollar<br>BMD-Bermuda Dollar<br>BTN-Bhutan Ngultrum<br>BOB-Bolivian Boliviano<br>BWP-Botswana Pula<br>BRL-Brazilian Real<br>GBP-British Pound<br>BND-Brunei Dollar<br>BIF-Burundi Franc<br>XOF-CFA Franc (BCEAO)<br>XAF-CFA Franc (BEAC)<br>KHR-Cambodia Riel<br>CAD-Canadian Dollar<br>CVE-Cape Verde Escudo<br>KYD-Cayman Islands Dollar<br>CLP-Chilean Peso<br>CNY-Chinese Yuan<br>COP-Colombian Peso<br>KMF-Comoros Franc<br>CRC-Costa Rica Colon<br>HRK-Croatian Kuna<br>CUP-Cuban Peso<br>CYP-Cyprus Pound<br>CZK-Czech Koruna<br>DKK-Danish Krone<br>DJF-Dijibouti Franc<br>DOP-Dominican Peso<br>XCD-East Caribbean Dollar<br>EGP-Egyptian Pound<br>SVC-El Salvador Colon<br>EEK-Estonian Kroon<br>ETB-Ethiopian Birr<br>EUR-Euro<br>FKP-Falkland Islands Pound<br>GMD-Gambian Dalasi<br>GHC-Ghanian Cedi<br>GIP-Gibraltar Pound<br>XAU-Gold Ounces<br>GTQ-Guatemala Quetzal<br>GNF-Guinea Franc<br>GYD-Guyana Dollar<br>HTG-Haiti Gourde<br>HNL-Honduras Lempira<br>HKD-Hong Kong Dollar<br>HUF-Hungarian Forint<br>ISK-Iceland Krona<br>INR-Indian Rupee<br>IDR-Indonesian Rupiah<br>IQD-Iraqi Dinar<br>ILS-Israeli Shekel<br>JMD-Jamaican Dollar<br>JPY-Japanese Yen<br>JOD-Jordanian Dinar<br>KZT-Kazakhstan Tenge<br>KES-Kenyan Shilling<br>KRW-Korean Won<br>KWD-Kuwaiti Dinar<br>LAK-Lao Kip<br>LVL-Latvian Lat<br>LBP-Lebanese Pound<br>LSL-Lesotho Loti<br>LRD-Liberian Dollar<br>LYD-Libyan Dinar<br>LTL-Lithuanian Lita<br>MOP-Macau Pataca<br>MKD-Macedonian Denar<br>MGF-Malagasy Franc<br>MWK-Malawi Kwacha<br>MYR-Malaysian Ringgit<br>MVR-Maldives Rufiyaa<br>MTL-Maltese Lira<br>MRO-Mauritania Ougulya<br>MUR-Mauritius Rupee<br>MXN-Mexican Peso<br>MDL-Moldovan Leu<br>MNT-Mongolian Tugrik<br>MAD-Moroccan Dirham<br>MZM-Mozambique Metical<br>MMK-Myanmar Kyat<br>NAD-Namibian Dollar<br>NPR-Nepalese Rupee<br>ANG-Neth Antilles Guilder<br>NZD-New Zealand Dollar<br>NIO-Nicaragua Cordoba<br>NGN-Nigerian Naira<br>KPW-North Korean Won<br>NOK-Norwegian Krone<br>OMR-Omani Rial<br>XPF-Pacific Franc<br>PKR-Pakistani Rupee<br>XPD-Palladium Ounces<br>PAB-Panama Balboa<br>PGK-Papua New Guinea Kina<br>PYG-Paraguayan Guarani<br>PEN-Peruvian Nuevo Sol<br>PHP-Philippine Peso<br>XPT-Platinum Ounces<br>PLN-Polish Zloty<br>QAR-Qatar Rial<br>ROL-Romanian Leu<br>RUB-Russian Rouble<br>WST-Samoa Tala<br>STD-Sao Tome Dobra<br>SAR-Saudi Arabian Riyal<br>SCR-Seychelles Rupee<br>SLL-Sierra Leone Leone<br>XAG-Silver Ounces<br>SGD-Singapore Dollar<br>SKK-Slovak Koruna<br>SIT-Slovenian Tolar<br>SBD-Solomon Islands Dollar<br>SOS-Somali Shilling<br>ZAR-South African Rand<br>LKR-Sri Lanka Rupee<br>SHP-St Helena Pound<br>SDD-Sudanese Dinar<br>SRG-Surinam Guilder<br>SZL-Swaziland Lilageni<br>SEK-Swedish Krona<br>TRY-Turkey Lira<br>CHF-Swiss Franc<br>SYP-Syrian Pound<br>TWD-Taiwan Dollar<br>TZS-Tanzanian Shilling<br>THB-Thai Baht<br>TOP-Tonga Pa'anga<br>TTD-Trinidad&amp;amp;Tobago Dollar<br>TND-Tunisian Dinar<br>TRL-Turkish Lira<br>USD-U.S. Dollar<br>AED-UAE Dirham<br>UGX-Ugandan Shilling<br>UAH-Ukraine Hryvnia<br>UYU-Uruguayan New Peso<br>VUV-Vanuatu Vatu<br>VEB-Venezuelan Bolivar<br>VND-Vietnam Dong<br>YER-Yemen Riyal<br>YUM-Yugoslav Dinar<br>ZMK-Zambian Kwacha<br>ZWD-Zimbabwe Dollar</font></p></blockquote> <br><b>Get conversion rate from one currency to another currency <b><br><p><b><font color='#000080' size='1' face='Verdana'><u>Differenct currency Code and Names around the world</u></font></b></p><blockquote><p><font face='Verdana' size='1'>AFA-Afghanistan Afghani<br>ALL-Albanian Lek<br>DZD-Algerian Dinar<br>ARS-Argentine Peso<br>AWG-Aruba Florin<br>AUD-Australian Dollar<br>BSD-Bahamian Dollar<br>BHD-Bahraini Dinar<br>BDT-Bangladesh Taka<br>BBD-Barbados Dollar<br>BZD-Belize Dollar<br>BMD-Bermuda Dollar<br>BTN-Bhutan Ngultrum<br>BOB-Bolivian Boliviano<br>BWP-Botswana Pula<br>BRL-Brazilian Real<br>GBP-British Pound<br>BND-Brunei Dollar<br>BIF-Burundi Franc<br>XOF-CFA Franc (BCEAO)<br>XAF-CFA Franc (BEAC)<br>KHR-Cambodia Riel<br>CAD-Canadian Dollar<br>CVE-Cape Verde Escudo<br>KYD-Cayman Islands Dollar<br>CLP-Chilean Peso<br>CNY-Chinese Yuan<br>COP-Colombian Peso<br>KMF-Comoros Franc<br>CRC-Costa Rica Colon<br>HRK-Croatian Kuna<br>CUP-Cuban Peso<br>CYP-Cyprus Pound<br>CZK-Czech Koruna<br>DKK-Danish Krone<br>DJF-Dijibouti Franc<br>DOP-Dominican Peso<br>XCD-East Caribbean Dollar<br>EGP-Egyptian Pound<br>SVC-El Salvador Colon<br>EEK-Estonian Kroon<br>ETB-Ethiopian Birr<br>EUR-Euro<br>FKP-Falkland Islands Pound<br>GMD-Gambian Dalasi<br>GHC-Ghanian Cedi<br>GIP-Gibraltar Pound<br>XAU-Gold Ounces<br>GTQ-Guatemala Quetzal<br>GNF-Guinea Franc<br>GYD-Guyana Dollar<br>HTG-Haiti Gourde<br>HNL-Honduras Lempira<br>HKD-Hong Kong Dollar<br>HUF-Hungarian Forint<br>ISK-Iceland Krona<br>INR-Indian Rupee<br>IDR-Indonesian Rupiah<br>IQD-Iraqi Dinar<br>ILS-Israeli Shekel<br>JMD-Jamaican Dollar<br>JPY-Japanese Yen<br>JOD-Jordanian Dinar<br>KZT-Kazakhstan Tenge<br>KES-Kenyan Shilling<br>KRW-Korean Won<br>KWD-Kuwaiti Dinar<br>LAK-Lao Kip<br>LVL-Latvian Lat<br>LBP-Lebanese Pound<br>LSL-Lesotho Loti<br>LRD-Liberian Dollar<br>LYD-Libyan Dinar<br>LTL-Lithuanian Lita<br>MOP-Macau Pataca<br>MKD-Macedonian Denar<br>MGF-Malagasy Franc<br>MWK-Malawi Kwacha<br>MYR-Malaysian Ringgit<br>MVR-Maldives Rufiyaa<br>MTL-Maltese Lira<br>MRO-Mauritania Ougulya<br>MUR-Mauritius Rupee<br>MXN-Mexican Peso<br>MDL-Moldovan Leu<br>MNT-Mongolian Tugrik<br>MAD-Moroccan Dirham<br>MZM-Mozambique Metical<br>MMK-Myanmar Kyat<br>NAD-Namibian Dollar<br>NPR-Nepalese Rupee<br>ANG-Neth Antilles Guilder<br>NZD-New Zealand Dollar<br>NIO-Nicaragua Cordoba<br>NGN-Nigerian Naira<br>KPW-North Korean Won<br>NOK-Norwegian Krone<br>OMR-Omani Rial<br>XPF-Pacific Franc<br>PKR-Pakistani Rupee<br>XPD-Palladium Ounces<br>PAB-Panama Balboa<br>PGK-Papua New Guinea Kina<br>PYG-Paraguayan Guarani<br>PEN-Peruvian Nuevo Sol<br>PHP-Philippine Peso<br>XPT-Platinum Ounces<br>PLN-Polish Zloty<br>QAR-Qatar Rial<br>ROL-Romanian Leu<br>RUB-Russian Rouble<br>WST-Samoa Tala<br>STD-Sao Tome Dobra<br>SAR-Saudi Arabian Riyal<br>SCR-Seychelles Rupee<br>SLL-Sierra Leone Leone<br>XAG-Silver Ounces<br>SGD-Singapore Dollar<br>SKK-Slovak Koruna<br>SIT-Slovenian Tolar<br>SBD-Solomon Islands Dollar<br>SOS-Somali Shilling<br>ZAR-South African Rand<br>LKR-Sri Lanka Rupee<br>SHP-St Helena Pound<br>SDD-Sudanese Dinar<br>SRG-Surinam Guilder<br>SZL-Swaziland Lilageni<br>SEK-Swedish Krona<br>TRY-Turkey Lira<br>CHF-Swiss Franc<br>SYP-Syrian Pound<br>TWD-Taiwan Dollar<br>TZS-Tanzanian Shilling<br>THB-Thai Baht<br>TOP-Tonga Pa'anga<br>TTD-Trinidad&amp;amp;Tobago Dollar<br>TND-Tunisian Dinar<br>TRL-Turkish Lira<br>USD-U.S. Dollar<br>AED-UAE Dirham<br>UGX-Ugandan Shilling<br>UAH-Ukraine Hryvnia<br>UYU-Uruguayan New Peso<br>VUV-Vanuatu Vatu<br>VEB-Venezuelan Bolivar<br>VND-Vietnam Dong<br>YER-Yemen Riyal<br>YUM-Yugoslav Dinar<br>ZMK-Zambian Kwacha<br>ZWD-Zimbabwe Dollar</font></p></blockquote> ================================================ FILE: soap-examples/pom.xml ================================================ 4.0.0 org.reficio soap-examples pom soap-examples org.reficio soap-ws 1.0.0-SNAPSHOT ../pom.xml quickstart arquillian testing ================================================ FILE: soap-examples/quickstart/pom.xml ================================================ 4.0.0 org.reficio quickstart jar soap-examples - quickstart org.reficio soap-examples 1.0.0-SNAPSHOT ../pom.xml org.reficio soap-builder ${project.version} org.reficio soap-test ${project.version} org.reficio soap-client ${project.version} org.reficio soap-server ${project.version} com.googlecode.guava-osgi guava-osgi commons-logging commons-logging junit junit test org.springframework spring-test ${spring.version} org.codehaus.groovy groovy-all 3.1.2.RELEASE org.apache.maven.plugins maven-site-plugin 3.1 true ================================================ FILE: soap-examples/quickstart/src/test/groovy/org/reficio/ws/quickstart/QuickStart.groovy ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.quickstart import groovy.xml.StreamingMarkupBuilder import groovy.xml.XmlUtil import org.junit.Rule import org.junit.Test import org.reficio.ws.builder.core.Wsdl import org.reficio.ws.client.core.SoapClient import org.reficio.ws.test.junit.Server import org.reficio.ws.test.junit.SoapRule class QuickStart { @Rule public SoapRule rule = new SoapRule(); @Test void invokeConversionRate() { // generate the message (the quickest way) String input = Wsdl.parse("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL") .binding().name("{http://www.webserviceX.NET/}CurrencyConvertorSoap").find() .operation().soapAction("http://www.webserviceX.NET/ConversionRate").find() .buildInputMessage() // modify the request providing real data def slurper = new XmlSlurper().parseText(input) slurper.Body.ConversionRate.FromCurrency = "CHF" slurper.Body.ConversionRate.ToCurrency = "PLN" input = toPrettyXml(slurper) println input; // construct the soap client and post the message SoapClient client = SoapClient.builder() .endpointUri("http://www.webservicex.net/CurrencyConvertor.asmx") .build(); String output = client.post("http://www.webserviceX.NET/ConversionRate", input); def response = new XmlSlurper().parseText(output) // print whole response and the conversion rate only println(toPrettyXml(response)) println "\n" + response.Body.ConversionRateResponse.ConversionRateResult.text() } def static toPrettyXml(xml) { XmlUtil.serialize(new StreamingMarkupBuilder().bind { mkp.yield xml }) } } ================================================ FILE: soap-examples/quickstart/src/test/java/org/reficio/ws/quickstart/SoapClientExamplesTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.quickstart; import org.custommonkey.xmlunit.XMLUnit; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.reficio.ws.SoapContext; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.SoapOperation; import org.reficio.ws.builder.core.Wsdl; import org.reficio.ws.client.core.SoapClient; import org.reficio.ws.common.ResourceUtils; import org.reficio.ws.server.core.SoapServer; import org.reficio.ws.server.responder.AutoResponder; import org.xml.sax.SAXException; import javax.wsdl.WSDLException; import javax.xml.namespace.QName; import java.io.IOException; import java.net.URL; import static org.junit.Assert.assertTrue; /** * @author Tom Bujok * @since 1.0.0 */ public class SoapClientExamplesTest { private static SoapServer server; private static final int port = 9797; private static final String contextPath = "/stockquote"; private static final URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath("/", "wsdl/stockquote-service.wsdl"); private static final QName bindingName = new QName("http://reficio.org/stockquote.wsdl", "StockQuoteSoapBinding"); private static SoapBuilder builder; @BeforeClass public static void startServer() throws WSDLException { server = SoapServer.builder() .httpPort(port) .build(); server.start(); AutoResponder responder = getAutoResponderForTestService(); server.registerRequestResponder(contextPath, responder); } @AfterClass public static void stopServer() { server.stop(); } public static AutoResponder getAutoResponderForTestService() throws WSDLException { SoapContext context = SoapContext.builder().exampleContent(false).build(); Wsdl parser = Wsdl.parse(wsdlUrl); builder = parser.binding().name(bindingName).find(); AutoResponder responder = new AutoResponder(builder, context); return responder; } /** * Here we're gonna generate the SOAP message using SoapBuilder and post it using SoapClient */ @Test public void invoke_tradePriceRequest_generatedMessages() throws Exception, SAXException, WSDLException { // construct the client String url = String.format("http://localhost:%d%s", port, contextPath); SoapClient client = SoapClient.builder() .endpointUri(url) .build(); Wsdl parser = Wsdl.parse(wsdlUrl); SoapBuilder soapBuilder = parser.binding().name(bindingName).find(); // get the operation to invoked -> assumption our operation is the first operation in the WSDL's SoapOperation operation = soapBuilder.operation().name("GetLastTradePrice").find(); // construct the request String request = soapBuilder.buildInputMessage(operation); // post the request to the server String response = client.post(request); // get the response String expectedResponse = soapBuilder.buildOutputMessage(operation, SoapContext.NO_CONTENT); assertTrue(XMLUnit.compareXML(expectedResponse, response).identical()); } /** * Here we're gonna simply post SOAP hardcoded message using SoapClient */ @Test public void invoke_tradePriceRequest_hardcodedMessages() throws IOException, SAXException { String url = String.format("http://localhost:%d%s", port, contextPath); SoapClient client = SoapClient.builder() .endpointUri(url) .build(); String request = "\n" + " \n" + " \n" + " \n" + " \n" + " ?\n" + " \n" + " \n" + " \n" + ""; String response = client.post(request); String expectedResponse = "" + "\n" + " \n" + " \n" + " \n" + " \n" + " ?\n" + " \n" + " \n" + " \n" + ""; assertTrue(XMLUnit.compareXML(expectedResponse, response).identical()); } } ================================================ FILE: soap-examples/quickstart/src/test/java/org/reficio/ws/quickstart/SoapServerExamplesTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.quickstart; import org.junit.Test; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.SoapOperation; import org.reficio.ws.builder.core.Wsdl; import org.reficio.ws.common.ResourceUtils; import org.reficio.ws.common.XmlUtils; import org.reficio.ws.server.core.SoapServer; import org.reficio.ws.server.responder.AbstractResponder; import org.reficio.ws.server.responder.AutoResponder; import org.springframework.ws.soap.SoapMessage; import javax.wsdl.WSDLException; import javax.xml.transform.Source; import java.net.URL; /** * @author Tom Bujok * @since 1.0.0 */ public class SoapServerExamplesTest { @Test public void createServer() { SoapServer server = SoapServer.builder() .httpPort(9090) .build(); server.start(); server.stop(); } @Test public void createServer_registerAutoResponder() throws WSDLException { SoapServer server = SoapServer.builder() .httpPort(9090) .build(); server.start(); URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath("/", "wsdl/stockquote-service.wsdl"); Wsdl parser = Wsdl.parse(wsdlUrl); SoapBuilder builder = parser.binding().localPart("StockQuoteSoapBinding").find(); AutoResponder responder = new AutoResponder(builder); server.registerRequestResponder("/service", responder); server.stop(); } @Test public void createServer_registerCustomResponder() throws WSDLException { SoapServer server = SoapServer.builder() .httpPort(9090) .build(); server.start(); URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath("/", "wsdl/stockquote-service.wsdl"); Wsdl parser = Wsdl.parse(wsdlUrl); final SoapBuilder builder = parser.binding().localPart("StockQuoteSoapBinding").find(); AbstractResponder customResponder = new AbstractResponder(builder) { @Override public Source respond(SoapOperation invokedOperation, SoapMessage message) { try { // build the response using builder String response = builder.buildOutputMessage(invokedOperation); // here you can tweak the response -> for example with XSLT //... return XmlUtils.xmlStringToSource(response); } catch (Exception e) { // will automatically generate SOAP-FAULT throw new RuntimeException("my custom error", e); } } }; server.registerRequestResponder("/service", customResponder); server.stop(); } } ================================================ FILE: soap-examples/quickstart/src/test/java/org/reficio/ws/quickstart/SpringExampleTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.quickstart; import org.apache.log4j.Logger; import org.junit.Test; import org.junit.runner.RunWith; import org.reficio.ws.SoapContext; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.SoapOperation; import org.reficio.ws.client.core.SoapClient; import org.reficio.ws.server.core.SoapServer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:applicationContext.xml") public class SpringExampleTest { private final static Logger log = Logger.getLogger(SpringExampleTest.class); @Autowired private SoapBuilder builder; @Autowired private SoapClient client; @Autowired private SoapServer server; @Test public void testInjection() { assertNotNull(builder); assertNotNull(server); } @Test public void testServerStarted() { assertTrue(server.isRunning()); } @Test public void testRequestResponse() { SoapOperation operation = builder.operation().name("ConversionRate").find(); SoapContext context = SoapContext.builder().exampleContent(true).build(); String request = builder.buildInputMessage(operation, context); String response = client.post(request); assertNotNull(response); } } ================================================ FILE: soap-examples/quickstart/src/test/resources/applicationContext.xml ================================================ wsdl/currency-convertor.wsdl http://www.webservicex.net/CurrencyConvertor.asmx?WSDL {http://www.webserviceX.NET/}CurrencyConvertorSoap ================================================ FILE: soap-examples/quickstart/src/test/resources/log4j.xml ================================================ ================================================ FILE: soap-examples/quickstart/src/test/resources/wsdl/currency-convertor.wsdl ================================================ <br><b>Get conversion rate from one currency to another currency <b><br><p><b><font color='#000080' size='1' face='Verdana'><u>Differenct currency Code and Names around the world</u></font></b></p><blockquote><p><font face='Verdana' size='1'>AFA-Afghanistan Afghani<br>ALL-Albanian Lek<br>DZD-Algerian Dinar<br>ARS-Argentine Peso<br>AWG-Aruba Florin<br>AUD-Australian Dollar<br>BSD-Bahamian Dollar<br>BHD-Bahraini Dinar<br>BDT-Bangladesh Taka<br>BBD-Barbados Dollar<br>BZD-Belize Dollar<br>BMD-Bermuda Dollar<br>BTN-Bhutan Ngultrum<br>BOB-Bolivian Boliviano<br>BWP-Botswana Pula<br>BRL-Brazilian Real<br>GBP-British Pound<br>BND-Brunei Dollar<br>BIF-Burundi Franc<br>XOF-CFA Franc (BCEAO)<br>XAF-CFA Franc (BEAC)<br>KHR-Cambodia Riel<br>CAD-Canadian Dollar<br>CVE-Cape Verde Escudo<br>KYD-Cayman Islands Dollar<br>CLP-Chilean Peso<br>CNY-Chinese Yuan<br>COP-Colombian Peso<br>KMF-Comoros Franc<br>CRC-Costa Rica Colon<br>HRK-Croatian Kuna<br>CUP-Cuban Peso<br>CYP-Cyprus Pound<br>CZK-Czech Koruna<br>DKK-Danish Krone<br>DJF-Dijibouti Franc<br>DOP-Dominican Peso<br>XCD-East Caribbean Dollar<br>EGP-Egyptian Pound<br>SVC-El Salvador Colon<br>EEK-Estonian Kroon<br>ETB-Ethiopian Birr<br>EUR-Euro<br>FKP-Falkland Islands Pound<br>GMD-Gambian Dalasi<br>GHC-Ghanian Cedi<br>GIP-Gibraltar Pound<br>XAU-Gold Ounces<br>GTQ-Guatemala Quetzal<br>GNF-Guinea Franc<br>GYD-Guyana Dollar<br>HTG-Haiti Gourde<br>HNL-Honduras Lempira<br>HKD-Hong Kong Dollar<br>HUF-Hungarian Forint<br>ISK-Iceland Krona<br>INR-Indian Rupee<br>IDR-Indonesian Rupiah<br>IQD-Iraqi Dinar<br>ILS-Israeli Shekel<br>JMD-Jamaican Dollar<br>JPY-Japanese Yen<br>JOD-Jordanian Dinar<br>KZT-Kazakhstan Tenge<br>KES-Kenyan Shilling<br>KRW-Korean Won<br>KWD-Kuwaiti Dinar<br>LAK-Lao Kip<br>LVL-Latvian Lat<br>LBP-Lebanese Pound<br>LSL-Lesotho Loti<br>LRD-Liberian Dollar<br>LYD-Libyan Dinar<br>LTL-Lithuanian Lita<br>MOP-Macau Pataca<br>MKD-Macedonian Denar<br>MGF-Malagasy Franc<br>MWK-Malawi Kwacha<br>MYR-Malaysian Ringgit<br>MVR-Maldives Rufiyaa<br>MTL-Maltese Lira<br>MRO-Mauritania Ougulya<br>MUR-Mauritius Rupee<br>MXN-Mexican Peso<br>MDL-Moldovan Leu<br>MNT-Mongolian Tugrik<br>MAD-Moroccan Dirham<br>MZM-Mozambique Metical<br>MMK-Myanmar Kyat<br>NAD-Namibian Dollar<br>NPR-Nepalese Rupee<br>ANG-Neth Antilles Guilder<br>NZD-New Zealand Dollar<br>NIO-Nicaragua Cordoba<br>NGN-Nigerian Naira<br>KPW-North Korean Won<br>NOK-Norwegian Krone<br>OMR-Omani Rial<br>XPF-Pacific Franc<br>PKR-Pakistani Rupee<br>XPD-Palladium Ounces<br>PAB-Panama Balboa<br>PGK-Papua New Guinea Kina<br>PYG-Paraguayan Guarani<br>PEN-Peruvian Nuevo Sol<br>PHP-Philippine Peso<br>XPT-Platinum Ounces<br>PLN-Polish Zloty<br>QAR-Qatar Rial<br>ROL-Romanian Leu<br>RUB-Russian Rouble<br>WST-Samoa Tala<br>STD-Sao Tome Dobra<br>SAR-Saudi Arabian Riyal<br>SCR-Seychelles Rupee<br>SLL-Sierra Leone Leone<br>XAG-Silver Ounces<br>SGD-Singapore Dollar<br>SKK-Slovak Koruna<br>SIT-Slovenian Tolar<br>SBD-Solomon Islands Dollar<br>SOS-Somali Shilling<br>ZAR-South African Rand<br>LKR-Sri Lanka Rupee<br>SHP-St Helena Pound<br>SDD-Sudanese Dinar<br>SRG-Surinam Guilder<br>SZL-Swaziland Lilageni<br>SEK-Swedish Krona<br>TRY-Turkey Lira<br>CHF-Swiss Franc<br>SYP-Syrian Pound<br>TWD-Taiwan Dollar<br>TZS-Tanzanian Shilling<br>THB-Thai Baht<br>TOP-Tonga Pa'anga<br>TTD-Trinidad&amp;amp;Tobago Dollar<br>TND-Tunisian Dinar<br>TRL-Turkish Lira<br>USD-U.S. Dollar<br>AED-UAE Dirham<br>UGX-Ugandan Shilling<br>UAH-Ukraine Hryvnia<br>UYU-Uruguayan New Peso<br>VUV-Vanuatu Vatu<br>VEB-Venezuelan Bolivar<br>VND-Vietnam Dong<br>YER-Yemen Riyal<br>YUM-Yugoslav Dinar<br>ZMK-Zambian Kwacha<br>ZWD-Zimbabwe Dollar</font></p></blockquote> <br><b>Get conversion rate from one currency to another currency <b><br><p><b><font color='#000080' size='1' face='Verdana'><u>Differenct currency Code and Names around the world</u></font></b></p><blockquote><p><font face='Verdana' size='1'>AFA-Afghanistan Afghani<br>ALL-Albanian Lek<br>DZD-Algerian Dinar<br>ARS-Argentine Peso<br>AWG-Aruba Florin<br>AUD-Australian Dollar<br>BSD-Bahamian Dollar<br>BHD-Bahraini Dinar<br>BDT-Bangladesh Taka<br>BBD-Barbados Dollar<br>BZD-Belize Dollar<br>BMD-Bermuda Dollar<br>BTN-Bhutan Ngultrum<br>BOB-Bolivian Boliviano<br>BWP-Botswana Pula<br>BRL-Brazilian Real<br>GBP-British Pound<br>BND-Brunei Dollar<br>BIF-Burundi Franc<br>XOF-CFA Franc (BCEAO)<br>XAF-CFA Franc (BEAC)<br>KHR-Cambodia Riel<br>CAD-Canadian Dollar<br>CVE-Cape Verde Escudo<br>KYD-Cayman Islands Dollar<br>CLP-Chilean Peso<br>CNY-Chinese Yuan<br>COP-Colombian Peso<br>KMF-Comoros Franc<br>CRC-Costa Rica Colon<br>HRK-Croatian Kuna<br>CUP-Cuban Peso<br>CYP-Cyprus Pound<br>CZK-Czech Koruna<br>DKK-Danish Krone<br>DJF-Dijibouti Franc<br>DOP-Dominican Peso<br>XCD-East Caribbean Dollar<br>EGP-Egyptian Pound<br>SVC-El Salvador Colon<br>EEK-Estonian Kroon<br>ETB-Ethiopian Birr<br>EUR-Euro<br>FKP-Falkland Islands Pound<br>GMD-Gambian Dalasi<br>GHC-Ghanian Cedi<br>GIP-Gibraltar Pound<br>XAU-Gold Ounces<br>GTQ-Guatemala Quetzal<br>GNF-Guinea Franc<br>GYD-Guyana Dollar<br>HTG-Haiti Gourde<br>HNL-Honduras Lempira<br>HKD-Hong Kong Dollar<br>HUF-Hungarian Forint<br>ISK-Iceland Krona<br>INR-Indian Rupee<br>IDR-Indonesian Rupiah<br>IQD-Iraqi Dinar<br>ILS-Israeli Shekel<br>JMD-Jamaican Dollar<br>JPY-Japanese Yen<br>JOD-Jordanian Dinar<br>KZT-Kazakhstan Tenge<br>KES-Kenyan Shilling<br>KRW-Korean Won<br>KWD-Kuwaiti Dinar<br>LAK-Lao Kip<br>LVL-Latvian Lat<br>LBP-Lebanese Pound<br>LSL-Lesotho Loti<br>LRD-Liberian Dollar<br>LYD-Libyan Dinar<br>LTL-Lithuanian Lita<br>MOP-Macau Pataca<br>MKD-Macedonian Denar<br>MGF-Malagasy Franc<br>MWK-Malawi Kwacha<br>MYR-Malaysian Ringgit<br>MVR-Maldives Rufiyaa<br>MTL-Maltese Lira<br>MRO-Mauritania Ougulya<br>MUR-Mauritius Rupee<br>MXN-Mexican Peso<br>MDL-Moldovan Leu<br>MNT-Mongolian Tugrik<br>MAD-Moroccan Dirham<br>MZM-Mozambique Metical<br>MMK-Myanmar Kyat<br>NAD-Namibian Dollar<br>NPR-Nepalese Rupee<br>ANG-Neth Antilles Guilder<br>NZD-New Zealand Dollar<br>NIO-Nicaragua Cordoba<br>NGN-Nigerian Naira<br>KPW-North Korean Won<br>NOK-Norwegian Krone<br>OMR-Omani Rial<br>XPF-Pacific Franc<br>PKR-Pakistani Rupee<br>XPD-Palladium Ounces<br>PAB-Panama Balboa<br>PGK-Papua New Guinea Kina<br>PYG-Paraguayan Guarani<br>PEN-Peruvian Nuevo Sol<br>PHP-Philippine Peso<br>XPT-Platinum Ounces<br>PLN-Polish Zloty<br>QAR-Qatar Rial<br>ROL-Romanian Leu<br>RUB-Russian Rouble<br>WST-Samoa Tala<br>STD-Sao Tome Dobra<br>SAR-Saudi Arabian Riyal<br>SCR-Seychelles Rupee<br>SLL-Sierra Leone Leone<br>XAG-Silver Ounces<br>SGD-Singapore Dollar<br>SKK-Slovak Koruna<br>SIT-Slovenian Tolar<br>SBD-Solomon Islands Dollar<br>SOS-Somali Shilling<br>ZAR-South African Rand<br>LKR-Sri Lanka Rupee<br>SHP-St Helena Pound<br>SDD-Sudanese Dinar<br>SRG-Surinam Guilder<br>SZL-Swaziland Lilageni<br>SEK-Swedish Krona<br>TRY-Turkey Lira<br>CHF-Swiss Franc<br>SYP-Syrian Pound<br>TWD-Taiwan Dollar<br>TZS-Tanzanian Shilling<br>THB-Thai Baht<br>TOP-Tonga Pa'anga<br>TTD-Trinidad&amp;amp;Tobago Dollar<br>TND-Tunisian Dinar<br>TRL-Turkish Lira<br>USD-U.S. Dollar<br>AED-UAE Dirham<br>UGX-Ugandan Shilling<br>UAH-Ukraine Hryvnia<br>UYU-Uruguayan New Peso<br>VUV-Vanuatu Vatu<br>VEB-Venezuelan Bolivar<br>VND-Vietnam Dong<br>YER-Yemen Riyal<br>YUM-Yugoslav Dinar<br>ZMK-Zambian Kwacha<br>ZWD-Zimbabwe Dollar</font></p></blockquote> <br><b>Get conversion rate from one currency to another currency <b><br><p><b><font color='#000080' size='1' face='Verdana'><u>Differenct currency Code and Names around the world</u></font></b></p><blockquote><p><font face='Verdana' size='1'>AFA-Afghanistan Afghani<br>ALL-Albanian Lek<br>DZD-Algerian Dinar<br>ARS-Argentine Peso<br>AWG-Aruba Florin<br>AUD-Australian Dollar<br>BSD-Bahamian Dollar<br>BHD-Bahraini Dinar<br>BDT-Bangladesh Taka<br>BBD-Barbados Dollar<br>BZD-Belize Dollar<br>BMD-Bermuda Dollar<br>BTN-Bhutan Ngultrum<br>BOB-Bolivian Boliviano<br>BWP-Botswana Pula<br>BRL-Brazilian Real<br>GBP-British Pound<br>BND-Brunei Dollar<br>BIF-Burundi Franc<br>XOF-CFA Franc (BCEAO)<br>XAF-CFA Franc (BEAC)<br>KHR-Cambodia Riel<br>CAD-Canadian Dollar<br>CVE-Cape Verde Escudo<br>KYD-Cayman Islands Dollar<br>CLP-Chilean Peso<br>CNY-Chinese Yuan<br>COP-Colombian Peso<br>KMF-Comoros Franc<br>CRC-Costa Rica Colon<br>HRK-Croatian Kuna<br>CUP-Cuban Peso<br>CYP-Cyprus Pound<br>CZK-Czech Koruna<br>DKK-Danish Krone<br>DJF-Dijibouti Franc<br>DOP-Dominican Peso<br>XCD-East Caribbean Dollar<br>EGP-Egyptian Pound<br>SVC-El Salvador Colon<br>EEK-Estonian Kroon<br>ETB-Ethiopian Birr<br>EUR-Euro<br>FKP-Falkland Islands Pound<br>GMD-Gambian Dalasi<br>GHC-Ghanian Cedi<br>GIP-Gibraltar Pound<br>XAU-Gold Ounces<br>GTQ-Guatemala Quetzal<br>GNF-Guinea Franc<br>GYD-Guyana Dollar<br>HTG-Haiti Gourde<br>HNL-Honduras Lempira<br>HKD-Hong Kong Dollar<br>HUF-Hungarian Forint<br>ISK-Iceland Krona<br>INR-Indian Rupee<br>IDR-Indonesian Rupiah<br>IQD-Iraqi Dinar<br>ILS-Israeli Shekel<br>JMD-Jamaican Dollar<br>JPY-Japanese Yen<br>JOD-Jordanian Dinar<br>KZT-Kazakhstan Tenge<br>KES-Kenyan Shilling<br>KRW-Korean Won<br>KWD-Kuwaiti Dinar<br>LAK-Lao Kip<br>LVL-Latvian Lat<br>LBP-Lebanese Pound<br>LSL-Lesotho Loti<br>LRD-Liberian Dollar<br>LYD-Libyan Dinar<br>LTL-Lithuanian Lita<br>MOP-Macau Pataca<br>MKD-Macedonian Denar<br>MGF-Malagasy Franc<br>MWK-Malawi Kwacha<br>MYR-Malaysian Ringgit<br>MVR-Maldives Rufiyaa<br>MTL-Maltese Lira<br>MRO-Mauritania Ougulya<br>MUR-Mauritius Rupee<br>MXN-Mexican Peso<br>MDL-Moldovan Leu<br>MNT-Mongolian Tugrik<br>MAD-Moroccan Dirham<br>MZM-Mozambique Metical<br>MMK-Myanmar Kyat<br>NAD-Namibian Dollar<br>NPR-Nepalese Rupee<br>ANG-Neth Antilles Guilder<br>NZD-New Zealand Dollar<br>NIO-Nicaragua Cordoba<br>NGN-Nigerian Naira<br>KPW-North Korean Won<br>NOK-Norwegian Krone<br>OMR-Omani Rial<br>XPF-Pacific Franc<br>PKR-Pakistani Rupee<br>XPD-Palladium Ounces<br>PAB-Panama Balboa<br>PGK-Papua New Guinea Kina<br>PYG-Paraguayan Guarani<br>PEN-Peruvian Nuevo Sol<br>PHP-Philippine Peso<br>XPT-Platinum Ounces<br>PLN-Polish Zloty<br>QAR-Qatar Rial<br>ROL-Romanian Leu<br>RUB-Russian Rouble<br>WST-Samoa Tala<br>STD-Sao Tome Dobra<br>SAR-Saudi Arabian Riyal<br>SCR-Seychelles Rupee<br>SLL-Sierra Leone Leone<br>XAG-Silver Ounces<br>SGD-Singapore Dollar<br>SKK-Slovak Koruna<br>SIT-Slovenian Tolar<br>SBD-Solomon Islands Dollar<br>SOS-Somali Shilling<br>ZAR-South African Rand<br>LKR-Sri Lanka Rupee<br>SHP-St Helena Pound<br>SDD-Sudanese Dinar<br>SRG-Surinam Guilder<br>SZL-Swaziland Lilageni<br>SEK-Swedish Krona<br>TRY-Turkey Lira<br>CHF-Swiss Franc<br>SYP-Syrian Pound<br>TWD-Taiwan Dollar<br>TZS-Tanzanian Shilling<br>THB-Thai Baht<br>TOP-Tonga Pa'anga<br>TTD-Trinidad&amp;amp;Tobago Dollar<br>TND-Tunisian Dinar<br>TRL-Turkish Lira<br>USD-U.S. Dollar<br>AED-UAE Dirham<br>UGX-Ugandan Shilling<br>UAH-Ukraine Hryvnia<br>UYU-Uruguayan New Peso<br>VUV-Vanuatu Vatu<br>VEB-Venezuelan Bolivar<br>VND-Vietnam Dong<br>YER-Yemen Riyal<br>YUM-Yugoslav Dinar<br>ZMK-Zambian Kwacha<br>ZWD-Zimbabwe Dollar</font></p></blockquote> ================================================ FILE: soap-examples/quickstart/src/test/resources/wsdl/stockquote-schema.xsd ================================================ ================================================ FILE: soap-examples/quickstart/src/test/resources/wsdl/stockquote-service.wsdl ================================================ My first service ================================================ FILE: soap-examples/testing/pom.xml ================================================ 4.0.0 org.reficio testing jar soap-examples - testing org.reficio soap-examples 1.0.0-SNAPSHOT ../pom.xml org.reficio soap-common ${project.version} org.reficio soap-builder ${project.version} xerces xercesImpl xml-apis xml-apis org.apache.xmlbeans xmlbeans-xmlpublic org.reficio soap-client ${project.version} org.reficio soap-server ${project.version} org.reficio soap-test ${project.version} org.springframework spring-test 3.1.2.RELEASE org.codehaus.gmaven.runtime gmaven-runtime-2.0 ${gmaven.version} org.codehaus.groovy groovy-all org.sonatype.gossip gossip org.codehaus.groovy groovy-all ${groovy.version} org.spockframework spock-core 0.7-groovy-2.0 ================================================ FILE: soap-examples/testing/src/test/groovy/org/reficio/sample/BankService.groovy ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.sample /** * @author: Tom Bujok (tom.bujok@gmail.com) * * Reficio™ - Reestablish your software! * www.reficio.org */ interface BankService { Double getExpenses(String account, String category); Double getExpenses(String account, String category, String currency); String getCurrency(); } ================================================ FILE: soap-examples/testing/src/test/groovy/org/reficio/sample/BankServiceImpl.groovy ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.sample import groovy.xml.StreamingMarkupBuilder import groovy.xml.XmlUtil import org.reficio.ws.builder.SoapBuilder import org.reficio.ws.builder.core.Wsdl import org.reficio.ws.client.core.SoapClient import org.reficio.ws.common.ResourceUtils /** * @author: Tom Bujok (tom.bujok@gmail.com) * * Reficio™ - Reestablish your software! * www.reficio.org */ class BankServiceImpl implements BankService { String conversionServiceUri SoapClient client; BankServiceImpl() { this.conversionServiceUri = "http://127.0.0.1:9090/service" } BankServiceImpl(String conversionServiceUri) { this.conversionServiceUri = conversionServiceUri } BankServiceImpl(SoapClient client) { this.client = client } Double getExpenses(String account, String category) { if (!account) { return -1 } else if (category == "BEER") { return 317 } else { return Random.newInstance().nextInt(1000) } } Double getExpenses(String account, String category, String currency) { Double balance = getExpenses(account, category) Double conversionRate = getConversionRate(getDefaultCurrency(), currency) return balance * conversionRate } String getCurrency() { return "GBP" } String getDefaultCurrency() { return "GBP" } Double getConversionRate(String fromCurrency, String toCurrency) { URL url = ResourceUtils.getResource("wsdl/currency-convertor.wsdl") Wsdl wsdl = Wsdl.parse(url) SoapBuilder builder = wsdl.binding().localPart("CurrencyConvertorSoap").find() String request = builder.operation().name("ConversionRate").find().buildInputMessage() def slurper = new XmlSlurper().parseText(request) slurper.Body.ConversionRate.FromCurrency = fromCurrency slurper.Body.ConversionRate.ToCurrency = toCurrency request = toPrettyXml(slurper) if (!client) { client = SoapClient.builder() .endpointUri(conversionServiceUri) .build() } String response = client.post(request) return parseResponse(response) } Double parseResponse(String response) { def slurper = new XmlSlurper().parseText(response) Double conversionRate = slurper.Body.ConversionRateResponse.ConversionRateResult.toString() as Double return conversionRate } String toPrettyXml(def xml) { XmlUtil.serialize(new StreamingMarkupBuilder().bind { mkp.yield xml }) } } ================================================ FILE: soap-examples/testing/src/test/groovy/org/reficio/sample/testing/BalanceClientPlainTest.groovy ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.sample.testing import org.junit.Rule import org.junit.Test import org.reficio.sample.BankService import org.reficio.sample.BankServiceImpl import org.reficio.ws.test.junit.Server import org.reficio.ws.test.junit.SoapRule import static org.junit.Assert.assertTrue /** * @author: Tom Bujok (tom.bujok@gmail.com) * * Reficio™ - Reestablish your software! * www.reficio.org */ class BalanceClientPlainTest { private BankService bankService = new BankServiceImpl() @Test void getBeerExpenses() { int expenses = bankService.getExpenses("CH01-1231-4141-2386", "BEER") // println "Beer expenses = " + expenses + " " + bankService.getCurrency() assertTrue(expenses < 350) } @Rule public SoapRule rule = new SoapRule(); @Test @Server(wsdl = "classpath:wsdl/currency-convertor.wsdl", binding = "CurrencyConvertorSoap", port = 9090) void getBeerExpensesInEuro() { int expenses = bankService.getExpenses("CH01-1231-4141-2386", "BEER", "EUR") // println "Beer expenses = " + expenses + " EUR" assertTrue(expenses < 450) } } ================================================ FILE: soap-examples/testing/src/test/groovy/org/reficio/sample/testing/BalanceClientSpringTest.groovy ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.sample.testing import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.reficio.sample.BankService import org.reficio.ws.builder.SoapBuilder import org.reficio.ws.builder.SoapOperation import org.reficio.ws.client.core.SoapClient import org.reficio.ws.server.core.SoapServer import org.reficio.ws.server.responder.AbstractResponder import org.reficio.ws.server.responder.RequestResponder import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.junit4.SpringJUnit4ClassRunner import org.springframework.ws.soap.SoapMessage import javax.xml.transform.Source import static org.junit.Assert.assertTrue import static org.reficio.sample.util.ExampleUtils.toPrettyXml import static org.reficio.ws.common.XmlUtils.xmlStringToSource /** * @author: Tom Bujok (tom.bujok@gmail.com) * * Reficio™ - Reestablish your software! * www.reficio.org */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:applicationContext.xml") class BalanceClientSpringTest { @Autowired private BankService balanceService @Autowired private SoapBuilder builder; @Autowired private SoapClient client; @Autowired private SoapServer server; @Before public void before() { RequestResponder responder = new AbstractResponder(builder) { @Override public Source respond(SoapOperation invokedOperation, SoapMessage message) { String response = builder.buildOutputMessage(invokedOperation) def slurper = new XmlSlurper().parseText(response) slurper.Body.ConversionRateResponse.ConversionRateResult = 2.0 response = toPrettyXml(slurper) // println response return xmlStringToSource(response) } } server.registerRequestResponder("/service", responder) } @After public void cleanup() { server.stop(); } @Test void getBeerExpensesInEuro() { int expenses = balanceService.getExpenses("CH01-1231-4141-2386", "BEER", "EUR") // println "Beer expenses = " + expenses + " EUR" assertTrue(expenses < 700) } } ================================================ FILE: soap-examples/testing/src/test/groovy/org/reficio/sample/testing/ConverterServerTest.groovy ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.sample.testing import org.reficio.ws.builder.core.Wsdl import org.reficio.ws.client.core.SoapClient import org.reficio.ws.common.ResourceUtils import org.reficio.ws.test.spock.Server import spock.lang.Specification import static org.reficio.sample.util.ExampleUtils.toPrettyXml /** * @author: Tom Bujok (tom.bujok@gmail.com) * * Reficio™ - Reestablish your software! * www.reficio.org */ class ConverterServerTest extends Specification { URL url = ResourceUtils.getResource("wsdl/currency-convertor.wsdl") String supplement(String message, String from, String to) { def slurper = new XmlSlurper().parseText(message) slurper.Body.ConversionRate.FromCurrency = from slurper.Body.ConversionRate.ToCurrency = to return toPrettyXml(slurper) } Double extractRate(String response) { def slurper = new XmlSlurper().parseText(response) Double conversionRate = slurper.Body.ConversionRateResponse.ConversionRateResult.toString() as Double return conversionRate } @Server(wsdl = "classpath:wsdl/currency-convertor.wsdl", binding = "CurrencyConvertorSoap", port = 9090) def "conversion rate test"() { setup: SoapClient client = SoapClient.builder() .endpointUri("http://127.0.0.1:9090/service") .build() String message = Wsdl.parse(url) .binding().localPart("CurrencyConvertorSoap").find() .operation().name("ConversionRate").find() .buildInputMessage() message = supplement(message, from, to) String response = client.post(message) Double rate = extractRate(response) expect: min < rate && rate < max where: from | to | min | max "EUR" | "CHF" | 1.112 | 1.784 "EUR" | "GBP" | 0.546 | 2.134 "GBP" | "CHF" | 1.152 | 3.863 } } ================================================ FILE: soap-examples/testing/src/test/groovy/org/reficio/sample/util/ExampleUtils.groovy ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.sample.util import groovy.xml.StreamingMarkupBuilder import groovy.xml.XmlUtil /** * @author: Tom Bujok (tom.bujok@gmail.com) * * Reficio™ - Reestablish your software! * www.reficio.org */ class ExampleUtils { def static toPrettyXml(xml) { XmlUtil.serialize(new StreamingMarkupBuilder().bind { mkp.yield xml }) } } ================================================ FILE: soap-examples/testing/src/test/resources/applicationContext.xml ================================================ wsdl/currency-convertor.wsdl {http://www.webserviceX.NET/}CurrencyConvertorSoap ================================================ FILE: soap-examples/testing/src/test/resources/log4j.xml ================================================ ================================================ FILE: soap-examples/testing/src/test/resources/wsdl/currency-convertor.wsdl ================================================ <br><b>Get conversion rate from one currency to another currency <b><br><p><b><font color='#000080' size='1' face='Verdana'><u>Differenct currency Code and Names around the world</u></font></b></p><blockquote><p><font face='Verdana' size='1'>AFA-Afghanistan Afghani<br>ALL-Albanian Lek<br>DZD-Algerian Dinar<br>ARS-Argentine Peso<br>AWG-Aruba Florin<br>AUD-Australian Dollar<br>BSD-Bahamian Dollar<br>BHD-Bahraini Dinar<br>BDT-Bangladesh Taka<br>BBD-Barbados Dollar<br>BZD-Belize Dollar<br>BMD-Bermuda Dollar<br>BTN-Bhutan Ngultrum<br>BOB-Bolivian Boliviano<br>BWP-Botswana Pula<br>BRL-Brazilian Real<br>GBP-British Pound<br>BND-Brunei Dollar<br>BIF-Burundi Franc<br>XOF-CFA Franc (BCEAO)<br>XAF-CFA Franc (BEAC)<br>KHR-Cambodia Riel<br>CAD-Canadian Dollar<br>CVE-Cape Verde Escudo<br>KYD-Cayman Islands Dollar<br>CLP-Chilean Peso<br>CNY-Chinese Yuan<br>COP-Colombian Peso<br>KMF-Comoros Franc<br>CRC-Costa Rica Colon<br>HRK-Croatian Kuna<br>CUP-Cuban Peso<br>CYP-Cyprus Pound<br>CZK-Czech Koruna<br>DKK-Danish Krone<br>DJF-Dijibouti Franc<br>DOP-Dominican Peso<br>XCD-East Caribbean Dollar<br>EGP-Egyptian Pound<br>SVC-El Salvador Colon<br>EEK-Estonian Kroon<br>ETB-Ethiopian Birr<br>EUR-Euro<br>FKP-Falkland Islands Pound<br>GMD-Gambian Dalasi<br>GHC-Ghanian Cedi<br>GIP-Gibraltar Pound<br>XAU-Gold Ounces<br>GTQ-Guatemala Quetzal<br>GNF-Guinea Franc<br>GYD-Guyana Dollar<br>HTG-Haiti Gourde<br>HNL-Honduras Lempira<br>HKD-Hong Kong Dollar<br>HUF-Hungarian Forint<br>ISK-Iceland Krona<br>INR-Indian Rupee<br>IDR-Indonesian Rupiah<br>IQD-Iraqi Dinar<br>ILS-Israeli Shekel<br>JMD-Jamaican Dollar<br>JPY-Japanese Yen<br>JOD-Jordanian Dinar<br>KZT-Kazakhstan Tenge<br>KES-Kenyan Shilling<br>KRW-Korean Won<br>KWD-Kuwaiti Dinar<br>LAK-Lao Kip<br>LVL-Latvian Lat<br>LBP-Lebanese Pound<br>LSL-Lesotho Loti<br>LRD-Liberian Dollar<br>LYD-Libyan Dinar<br>LTL-Lithuanian Lita<br>MOP-Macau Pataca<br>MKD-Macedonian Denar<br>MGF-Malagasy Franc<br>MWK-Malawi Kwacha<br>MYR-Malaysian Ringgit<br>MVR-Maldives Rufiyaa<br>MTL-Maltese Lira<br>MRO-Mauritania Ougulya<br>MUR-Mauritius Rupee<br>MXN-Mexican Peso<br>MDL-Moldovan Leu<br>MNT-Mongolian Tugrik<br>MAD-Moroccan Dirham<br>MZM-Mozambique Metical<br>MMK-Myanmar Kyat<br>NAD-Namibian Dollar<br>NPR-Nepalese Rupee<br>ANG-Neth Antilles Guilder<br>NZD-New Zealand Dollar<br>NIO-Nicaragua Cordoba<br>NGN-Nigerian Naira<br>KPW-North Korean Won<br>NOK-Norwegian Krone<br>OMR-Omani Rial<br>XPF-Pacific Franc<br>PKR-Pakistani Rupee<br>XPD-Palladium Ounces<br>PAB-Panama Balboa<br>PGK-Papua New Guinea Kina<br>PYG-Paraguayan Guarani<br>PEN-Peruvian Nuevo Sol<br>PHP-Philippine Peso<br>XPT-Platinum Ounces<br>PLN-Polish Zloty<br>QAR-Qatar Rial<br>ROL-Romanian Leu<br>RUB-Russian Rouble<br>WST-Samoa Tala<br>STD-Sao Tome Dobra<br>SAR-Saudi Arabian Riyal<br>SCR-Seychelles Rupee<br>SLL-Sierra Leone Leone<br>XAG-Silver Ounces<br>SGD-Singapore Dollar<br>SKK-Slovak Koruna<br>SIT-Slovenian Tolar<br>SBD-Solomon Islands Dollar<br>SOS-Somali Shilling<br>ZAR-South African Rand<br>LKR-Sri Lanka Rupee<br>SHP-St Helena Pound<br>SDD-Sudanese Dinar<br>SRG-Surinam Guilder<br>SZL-Swaziland Lilageni<br>SEK-Swedish Krona<br>TRY-Turkey Lira<br>CHF-Swiss Franc<br>SYP-Syrian Pound<br>TWD-Taiwan Dollar<br>TZS-Tanzanian Shilling<br>THB-Thai Baht<br>TOP-Tonga Pa'anga<br>TTD-Trinidad&amp;amp;Tobago Dollar<br>TND-Tunisian Dinar<br>TRL-Turkish Lira<br>USD-U.S. Dollar<br>AED-UAE Dirham<br>UGX-Ugandan Shilling<br>UAH-Ukraine Hryvnia<br>UYU-Uruguayan New Peso<br>VUV-Vanuatu Vatu<br>VEB-Venezuelan Bolivar<br>VND-Vietnam Dong<br>YER-Yemen Riyal<br>YUM-Yugoslav Dinar<br>ZMK-Zambian Kwacha<br>ZWD-Zimbabwe Dollar</font></p></blockquote> <br><b>Get conversion rate from one currency to another currency <b><br><p><b><font color='#000080' size='1' face='Verdana'><u>Differenct currency Code and Names around the world</u></font></b></p><blockquote><p><font face='Verdana' size='1'>AFA-Afghanistan Afghani<br>ALL-Albanian Lek<br>DZD-Algerian Dinar<br>ARS-Argentine Peso<br>AWG-Aruba Florin<br>AUD-Australian Dollar<br>BSD-Bahamian Dollar<br>BHD-Bahraini Dinar<br>BDT-Bangladesh Taka<br>BBD-Barbados Dollar<br>BZD-Belize Dollar<br>BMD-Bermuda Dollar<br>BTN-Bhutan Ngultrum<br>BOB-Bolivian Boliviano<br>BWP-Botswana Pula<br>BRL-Brazilian Real<br>GBP-British Pound<br>BND-Brunei Dollar<br>BIF-Burundi Franc<br>XOF-CFA Franc (BCEAO)<br>XAF-CFA Franc (BEAC)<br>KHR-Cambodia Riel<br>CAD-Canadian Dollar<br>CVE-Cape Verde Escudo<br>KYD-Cayman Islands Dollar<br>CLP-Chilean Peso<br>CNY-Chinese Yuan<br>COP-Colombian Peso<br>KMF-Comoros Franc<br>CRC-Costa Rica Colon<br>HRK-Croatian Kuna<br>CUP-Cuban Peso<br>CYP-Cyprus Pound<br>CZK-Czech Koruna<br>DKK-Danish Krone<br>DJF-Dijibouti Franc<br>DOP-Dominican Peso<br>XCD-East Caribbean Dollar<br>EGP-Egyptian Pound<br>SVC-El Salvador Colon<br>EEK-Estonian Kroon<br>ETB-Ethiopian Birr<br>EUR-Euro<br>FKP-Falkland Islands Pound<br>GMD-Gambian Dalasi<br>GHC-Ghanian Cedi<br>GIP-Gibraltar Pound<br>XAU-Gold Ounces<br>GTQ-Guatemala Quetzal<br>GNF-Guinea Franc<br>GYD-Guyana Dollar<br>HTG-Haiti Gourde<br>HNL-Honduras Lempira<br>HKD-Hong Kong Dollar<br>HUF-Hungarian Forint<br>ISK-Iceland Krona<br>INR-Indian Rupee<br>IDR-Indonesian Rupiah<br>IQD-Iraqi Dinar<br>ILS-Israeli Shekel<br>JMD-Jamaican Dollar<br>JPY-Japanese Yen<br>JOD-Jordanian Dinar<br>KZT-Kazakhstan Tenge<br>KES-Kenyan Shilling<br>KRW-Korean Won<br>KWD-Kuwaiti Dinar<br>LAK-Lao Kip<br>LVL-Latvian Lat<br>LBP-Lebanese Pound<br>LSL-Lesotho Loti<br>LRD-Liberian Dollar<br>LYD-Libyan Dinar<br>LTL-Lithuanian Lita<br>MOP-Macau Pataca<br>MKD-Macedonian Denar<br>MGF-Malagasy Franc<br>MWK-Malawi Kwacha<br>MYR-Malaysian Ringgit<br>MVR-Maldives Rufiyaa<br>MTL-Maltese Lira<br>MRO-Mauritania Ougulya<br>MUR-Mauritius Rupee<br>MXN-Mexican Peso<br>MDL-Moldovan Leu<br>MNT-Mongolian Tugrik<br>MAD-Moroccan Dirham<br>MZM-Mozambique Metical<br>MMK-Myanmar Kyat<br>NAD-Namibian Dollar<br>NPR-Nepalese Rupee<br>ANG-Neth Antilles Guilder<br>NZD-New Zealand Dollar<br>NIO-Nicaragua Cordoba<br>NGN-Nigerian Naira<br>KPW-North Korean Won<br>NOK-Norwegian Krone<br>OMR-Omani Rial<br>XPF-Pacific Franc<br>PKR-Pakistani Rupee<br>XPD-Palladium Ounces<br>PAB-Panama Balboa<br>PGK-Papua New Guinea Kina<br>PYG-Paraguayan Guarani<br>PEN-Peruvian Nuevo Sol<br>PHP-Philippine Peso<br>XPT-Platinum Ounces<br>PLN-Polish Zloty<br>QAR-Qatar Rial<br>ROL-Romanian Leu<br>RUB-Russian Rouble<br>WST-Samoa Tala<br>STD-Sao Tome Dobra<br>SAR-Saudi Arabian Riyal<br>SCR-Seychelles Rupee<br>SLL-Sierra Leone Leone<br>XAG-Silver Ounces<br>SGD-Singapore Dollar<br>SKK-Slovak Koruna<br>SIT-Slovenian Tolar<br>SBD-Solomon Islands Dollar<br>SOS-Somali Shilling<br>ZAR-South African Rand<br>LKR-Sri Lanka Rupee<br>SHP-St Helena Pound<br>SDD-Sudanese Dinar<br>SRG-Surinam Guilder<br>SZL-Swaziland Lilageni<br>SEK-Swedish Krona<br>TRY-Turkey Lira<br>CHF-Swiss Franc<br>SYP-Syrian Pound<br>TWD-Taiwan Dollar<br>TZS-Tanzanian Shilling<br>THB-Thai Baht<br>TOP-Tonga Pa'anga<br>TTD-Trinidad&amp;amp;Tobago Dollar<br>TND-Tunisian Dinar<br>TRL-Turkish Lira<br>USD-U.S. Dollar<br>AED-UAE Dirham<br>UGX-Ugandan Shilling<br>UAH-Ukraine Hryvnia<br>UYU-Uruguayan New Peso<br>VUV-Vanuatu Vatu<br>VEB-Venezuelan Bolivar<br>VND-Vietnam Dong<br>YER-Yemen Riyal<br>YUM-Yugoslav Dinar<br>ZMK-Zambian Kwacha<br>ZWD-Zimbabwe Dollar</font></p></blockquote> <br><b>Get conversion rate from one currency to another currency <b><br><p><b><font color='#000080' size='1' face='Verdana'><u>Differenct currency Code and Names around the world</u></font></b></p><blockquote><p><font face='Verdana' size='1'>AFA-Afghanistan Afghani<br>ALL-Albanian Lek<br>DZD-Algerian Dinar<br>ARS-Argentine Peso<br>AWG-Aruba Florin<br>AUD-Australian Dollar<br>BSD-Bahamian Dollar<br>BHD-Bahraini Dinar<br>BDT-Bangladesh Taka<br>BBD-Barbados Dollar<br>BZD-Belize Dollar<br>BMD-Bermuda Dollar<br>BTN-Bhutan Ngultrum<br>BOB-Bolivian Boliviano<br>BWP-Botswana Pula<br>BRL-Brazilian Real<br>GBP-British Pound<br>BND-Brunei Dollar<br>BIF-Burundi Franc<br>XOF-CFA Franc (BCEAO)<br>XAF-CFA Franc (BEAC)<br>KHR-Cambodia Riel<br>CAD-Canadian Dollar<br>CVE-Cape Verde Escudo<br>KYD-Cayman Islands Dollar<br>CLP-Chilean Peso<br>CNY-Chinese Yuan<br>COP-Colombian Peso<br>KMF-Comoros Franc<br>CRC-Costa Rica Colon<br>HRK-Croatian Kuna<br>CUP-Cuban Peso<br>CYP-Cyprus Pound<br>CZK-Czech Koruna<br>DKK-Danish Krone<br>DJF-Dijibouti Franc<br>DOP-Dominican Peso<br>XCD-East Caribbean Dollar<br>EGP-Egyptian Pound<br>SVC-El Salvador Colon<br>EEK-Estonian Kroon<br>ETB-Ethiopian Birr<br>EUR-Euro<br>FKP-Falkland Islands Pound<br>GMD-Gambian Dalasi<br>GHC-Ghanian Cedi<br>GIP-Gibraltar Pound<br>XAU-Gold Ounces<br>GTQ-Guatemala Quetzal<br>GNF-Guinea Franc<br>GYD-Guyana Dollar<br>HTG-Haiti Gourde<br>HNL-Honduras Lempira<br>HKD-Hong Kong Dollar<br>HUF-Hungarian Forint<br>ISK-Iceland Krona<br>INR-Indian Rupee<br>IDR-Indonesian Rupiah<br>IQD-Iraqi Dinar<br>ILS-Israeli Shekel<br>JMD-Jamaican Dollar<br>JPY-Japanese Yen<br>JOD-Jordanian Dinar<br>KZT-Kazakhstan Tenge<br>KES-Kenyan Shilling<br>KRW-Korean Won<br>KWD-Kuwaiti Dinar<br>LAK-Lao Kip<br>LVL-Latvian Lat<br>LBP-Lebanese Pound<br>LSL-Lesotho Loti<br>LRD-Liberian Dollar<br>LYD-Libyan Dinar<br>LTL-Lithuanian Lita<br>MOP-Macau Pataca<br>MKD-Macedonian Denar<br>MGF-Malagasy Franc<br>MWK-Malawi Kwacha<br>MYR-Malaysian Ringgit<br>MVR-Maldives Rufiyaa<br>MTL-Maltese Lira<br>MRO-Mauritania Ougulya<br>MUR-Mauritius Rupee<br>MXN-Mexican Peso<br>MDL-Moldovan Leu<br>MNT-Mongolian Tugrik<br>MAD-Moroccan Dirham<br>MZM-Mozambique Metical<br>MMK-Myanmar Kyat<br>NAD-Namibian Dollar<br>NPR-Nepalese Rupee<br>ANG-Neth Antilles Guilder<br>NZD-New Zealand Dollar<br>NIO-Nicaragua Cordoba<br>NGN-Nigerian Naira<br>KPW-North Korean Won<br>NOK-Norwegian Krone<br>OMR-Omani Rial<br>XPF-Pacific Franc<br>PKR-Pakistani Rupee<br>XPD-Palladium Ounces<br>PAB-Panama Balboa<br>PGK-Papua New Guinea Kina<br>PYG-Paraguayan Guarani<br>PEN-Peruvian Nuevo Sol<br>PHP-Philippine Peso<br>XPT-Platinum Ounces<br>PLN-Polish Zloty<br>QAR-Qatar Rial<br>ROL-Romanian Leu<br>RUB-Russian Rouble<br>WST-Samoa Tala<br>STD-Sao Tome Dobra<br>SAR-Saudi Arabian Riyal<br>SCR-Seychelles Rupee<br>SLL-Sierra Leone Leone<br>XAG-Silver Ounces<br>SGD-Singapore Dollar<br>SKK-Slovak Koruna<br>SIT-Slovenian Tolar<br>SBD-Solomon Islands Dollar<br>SOS-Somali Shilling<br>ZAR-South African Rand<br>LKR-Sri Lanka Rupee<br>SHP-St Helena Pound<br>SDD-Sudanese Dinar<br>SRG-Surinam Guilder<br>SZL-Swaziland Lilageni<br>SEK-Swedish Krona<br>TRY-Turkey Lira<br>CHF-Swiss Franc<br>SYP-Syrian Pound<br>TWD-Taiwan Dollar<br>TZS-Tanzanian Shilling<br>THB-Thai Baht<br>TOP-Tonga Pa'anga<br>TTD-Trinidad&amp;amp;Tobago Dollar<br>TND-Tunisian Dinar<br>TRL-Turkish Lira<br>USD-U.S. Dollar<br>AED-UAE Dirham<br>UGX-Ugandan Shilling<br>UAH-Ukraine Hryvnia<br>UYU-Uruguayan New Peso<br>VUV-Vanuatu Vatu<br>VEB-Venezuelan Bolivar<br>VND-Vietnam Dong<br>YER-Yemen Riyal<br>YUM-Yugoslav Dinar<br>ZMK-Zambian Kwacha<br>ZWD-Zimbabwe Dollar</font></p></blockquote> ================================================ FILE: soap-it/pom.xml ================================================ 4.0.0 org.reficio soap-it jar soap-it - integration tests org.reficio soap-ws 1.0.0-SNAPSHOT ../pom.xml org.reficio soap-builder ${project.version} test org.reficio soap-client ${project.version} test org.reficio soap-server ${project.version} test com.googlecode.guava-osgi guava-osgi test junit junit test org.littleshoot littleproxy 0.4 test org.apache.maven.plugins maven-site-plugin 3.1 true ================================================ FILE: soap-it/src/test/java/org/reficio/ws/it/AbstractCooperationTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.it; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.reficio.ws.SoapContext; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.SoapOperation; import org.reficio.ws.builder.core.SoapUtils; import org.reficio.ws.builder.core.Wsdl; import org.reficio.ws.client.core.SoapClient; import org.reficio.ws.common.ResourceUtils; import org.reficio.ws.common.XmlUtils; import org.reficio.ws.it.util.ClientBuilder; import org.reficio.ws.it.util.TestUtils; import org.reficio.ws.server.core.SoapServer; import javax.wsdl.Binding; import javax.wsdl.BindingOperation; import javax.wsdl.OperationType; import javax.wsdl.WSDLException; import javax.xml.namespace.QName; import java.io.InputStream; import java.net.URL; import java.security.KeyStore; import static junit.framework.Assert.assertTrue; /** * Abstract SoapServer<->SoapClient integration test with lots of convenience methods. * Basically, what it does is: * - read the test set from the resources folder -> test set id is passed to the reader * - starts the soap server and registers an auto-responder for the specified WSDL * - generates an XML request and response for every operation in the WSDL * - creates a SoapClient and post the XML request to the Server * - receives the response from the server and compares it to the response generated locally by the client. * * @author Tom Bujok * @since 1.0.0 */ public abstract class AbstractCooperationTest { private final static Log log = LogFactory.getLog(AbstractCooperationTest.class); public static final String HOST_URL = "localhost"; public static final int HOST_PORT = 9696; protected SoapServer server; protected static URL getKeyStoreUrlOne() { return ResourceUtils.getResourceWithAbsolutePackagePath("/keystores/single-cert-keystore", ".keystore_1"); } protected static URL getKeyStoreUrlTwo() { return ResourceUtils.getResourceWithAbsolutePackagePath("/keystores/single-cert-keystore", ".keystore_2"); } protected static URL getMultiKeyStoreUrl() { return ResourceUtils.getResourceWithAbsolutePackagePath("/keystores/multi-cert-keystore", ".keystore"); } protected String getKeyStorePassword() { return "changeit"; } protected void verifyServiceBehavior(int testServiceId, ClientBuilder clientBuilder) throws Exception { verifyServiceBehavior(testServiceId, null, clientBuilder); } protected void verifyServiceBehavior(int testServiceId) throws Exception { verifyServiceBehavior(testServiceId, new ClientBuilderImpl()); } protected void verifyServiceBehavior(int testServiceId, Boolean postSoapAction, ClientBuilder clientBuilder) throws Exception { log.info(String.format("------------------- TESTING SERVICE [%d] -----------------------", testServiceId)); Wsdl parser = TestUtils.createParserForService(testServiceId); registerHandler(server, testServiceId, parser); for (QName bindingName : parser.getBindings()) { SoapBuilder builder = parser.binding().name(bindingName).find(); String contextPath = TestUtils.formatContextPath(testServiceId, builder.getBindingName()); String endpointUrl = formatEndpointAddress(contextPath); for (SoapOperation operation : builder.getOperations()) { if (postSoapAction == null) { // test both with and without soap action testOperation(clientBuilder, builder, operation, endpointUrl, Boolean.TRUE); testOperation(clientBuilder, builder, operation, endpointUrl, Boolean.FALSE); } else { testOperation(clientBuilder, builder, operation, endpointUrl, postSoapAction); } } } } protected void verifyServiceBehavior(int testServiceId, Boolean postSoapAction) throws Exception { verifyServiceBehavior(testServiceId, postSoapAction, new ClientBuilderImpl()); } private void testOperation(ClientBuilder clientBuilder, SoapBuilder soapBuilder, SoapOperation operation, String endpointUrl, Boolean postSoapAction) throws Exception { log.info("Testing operation: " + operation); String request = soapBuilder.buildInputMessage(operation); if (!operation.isInputSoapEncoded()) { soapBuilder.validateInputMessage(operation, request); } assertTrue("Generated request is empty!", request.length() > 0); Binding binding = soapBuilder.getBinding(); BindingOperation op = binding.getBindingOperation(operation.getOperationName(), operation.getOperationInputName(), operation.getOperationOutputName()); String response; SoapClient client = clientBuilder.buildClient(endpointUrl); if (postSoapAction.booleanValue()) { String soapAction = SoapUtils.getSOAPActionUri(op); response = postRequest(client, request, soapAction); } else { response = postRequest(client, request); } SoapContext context = SoapContext.builder().exampleContent(true).build(); if (op.getOperation().getStyle().equals(OperationType.REQUEST_RESPONSE)) { String expectedResponse = soapBuilder.buildOutputMessage(operation, context); if (!operation.isOutputSoapEncoded()) { soapBuilder.validateOutputMessage(operation, response); } assertTrue("Generated expectedResponse is empty!", expectedResponse.length() > 0); boolean identical = XmlUtils.isIdenticalNormalizedWithoutValues(expectedResponse, response); assertTrue("Error during validation of service " + endpointUrl, identical); } } private void registerHandler(SoapServer server, int testServiceId, Wsdl parser) throws WSDLException { TestUtils.registerService(server, testServiceId, parser); } private String formatEndpointAddress(String contextPath) { return String.format("%s:%s%s", HOST_URL, HOST_PORT, contextPath); } private String postRequest(SoapClient client, String request) { return client.post(request); } private String postRequest(SoapClient client, String request, String soapAction) { return client.post(soapAction, request); } class ClientBuilderImpl implements ClientBuilder { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("http://" + endpointUrl).build(); } } protected KeyStore readKeyStore(URL keyStoreUrl, String keyStorePassword, String keyStoreType) { InputStream in = null; try { in = keyStoreUrl.openStream(); KeyStore ks = KeyStore.getInstance(keyStoreType); ks.load(in, keyStorePassword.toCharArray()); return ks; } catch (Exception e) { throw new RuntimeException(e); } } } ================================================ FILE: soap-it/src/test/java/org/reficio/ws/it/HttpCooperationTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.it; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.reficio.ws.client.TransmissionException; import org.reficio.ws.server.core.SoapServer; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; /** * Test SoapServer<->SoapClient communication using plain HTTP connection * * @author Tom Bujok * @since 1.0.0 */ public class HttpCooperationTest extends AbstractCooperationTest { private final static boolean SKIP_SOAP_ACTION = false; private final static boolean POST_SOAP_ACTION = true; @Before public void initializeServer() { server = SoapServer.builder() .httpPort(HOST_PORT) .build(); server.start(); } @After public void destroyServer() { server.stop(); } @Test public void testService1() throws Exception { verifyServiceBehavior(1); } @Test public void testService2() throws Exception { verifyServiceBehavior(2); } @Test public void testService3() throws Exception { verifyServiceBehavior(3); } @Test public void testService4() throws Exception { verifyServiceBehavior(4); } @Test public void testService5() throws Exception { verifyServiceBehavior(5); } @Test public void testService6() throws Exception { verifyServiceBehavior(6); } @Test public void testService7() throws Exception { verifyServiceBehavior(7); } @Test public void testService8() throws Exception { verifyServiceBehavior(8); } @Test public void testService9() throws Exception { verifyServiceBehavior(9); } @Test public void testService10() throws Exception { verifyServiceBehavior(10); } @Test public void testService11() throws Exception { verifyServiceBehavior(11); } @Test public void testService12() throws Exception { verifyServiceBehavior(12); } @Test public void testService13() throws Exception { verifyServiceBehavior(13); } @Test public void testService14() throws Exception { verifyServiceBehavior(14); } @Test public void testService15_noSoapAction() throws Exception { TransmissionException expected = null; try { verifyServiceBehavior(15, SKIP_SOAP_ACTION); } catch (TransmissionException ex) { expected = ex; } assertNotNull(expected); assertEquals(Integer.valueOf(500), expected.getErrorCode()); } @Test public void testService15_withSoapAction() throws Exception { verifyServiceBehavior(15, POST_SOAP_ACTION); } @Test public void testService16() throws Exception { verifyServiceBehavior(16); } @Test public void testService17() throws Exception { verifyServiceBehavior(17); } @Test public void testService18() throws Exception { verifyServiceBehavior(18); } @Test public void testService19() throws Exception { verifyServiceBehavior(19); } @Test public void testService20() throws Exception { verifyServiceBehavior(20); } @Test public void testService22() throws Exception { verifyServiceBehavior(22); } @Test public void testService23() throws Exception { TransmissionException expected = null; try { verifyServiceBehavior(23); } catch (TransmissionException ex) { expected = ex; } assertNotNull(expected); assertEquals(Integer.valueOf(500), expected.getErrorCode()); } @Test public void testService25() throws Exception { verifyServiceBehavior(25, POST_SOAP_ACTION); } @Test public void testService26() throws Exception { verifyServiceBehavior(26); } // TODO add WSDL validation // @Test // not a valid WSDL test public void testService27() throws Exception { verifyServiceBehavior(27); } } ================================================ FILE: soap-it/src/test/java/org/reficio/ws/it/HttpProxyHttpCooperationTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.it; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.littleshoot.proxy.DefaultHttpProxyServer; import org.littleshoot.proxy.HttpProxyServer; import org.littleshoot.proxy.ProxyAuthorizationHandler; import org.reficio.ws.client.TransmissionException; import org.reficio.ws.client.core.Security; import org.reficio.ws.client.core.SoapClient; import org.reficio.ws.it.util.ClientBuilder; import org.reficio.ws.server.core.SoapServer; /** * Test SoapServer<->SoapClient communication using HTTPS * * @author Tom Bujok * @since 1.0.0 */ public class HttpProxyHttpCooperationTest extends AbstractCooperationTest { @Rule public ExpectedException exception = ExpectedException.none(); private final static int PROXY_PORT = 9797; @Before public void initializeServer() { server = SoapServer.builder() .httpPort(HOST_PORT) .build(); server.start(); } @After public void destroyServer() { server.stop(); } public HttpProxyServer initProxy() { HttpProxyServer proxyServer = new DefaultHttpProxyServer(PROXY_PORT); proxyServer.start(true, true); return proxyServer; } @Test public void testService1_httpProxy_defaultProxySetting() throws Exception { HttpProxyServer proxyServer = initProxy(); try { verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("http://" + endpointUrl) .build(); } }); } finally { proxyServer.stop(); } } @Test public void testService1_httpProxy_directProxy() throws Exception { HttpProxyServer proxyServer = initProxy(); try { verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("http://" + endpointUrl) .build(); } }); } finally { proxyServer.stop(); } } @Test public void testService1_httpProxy_noAuthentication() throws Exception { HttpProxyServer proxyServer = initProxy(); try { verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("http://" + endpointUrl) .proxyUri("http://127.0.0.1:" + PROXY_PORT) .build(); } }); } finally { proxyServer.stop(); } } @Test public void testService1_httpProxy_basicAuthentication_success() throws Exception { HttpProxyServer proxyServer = initProxy(); proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() { @Override public boolean authenticate(String user, String pass) { return user.equals("tom") && pass.equals("007"); } }); try { final Security security = Security.builder() .authBasic("tom", "007") .build(); verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder() .endpointUri("http://" + endpointUrl) .proxyUri("http://127.0.0.1:" + PROXY_PORT) .proxySecurity(security) .build(); } }); } finally { proxyServer.stop(); } } @Test public void testService1_httpProxy_basicAuthentication_failure() throws Exception { exception.expect(TransmissionException.class); exception.expectMessage("[407]"); HttpProxyServer proxyServer = initProxy(); proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() { @Override public boolean authenticate(String user, String pass) { return user.equals("tom") && pass.equals("007"); } }); final Security props = Security.builder() .authBasic("james", "003") .build(); try { verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("http://" + endpointUrl) .proxyUri("http://127.0.0.1:" + PROXY_PORT) .proxySecurity(props) .build(); } }); } finally { proxyServer.stop(); } } } ================================================ FILE: soap-it/src/test/java/org/reficio/ws/it/HttpProxyHttpsCooperationTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.it; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.littleshoot.proxy.DefaultHttpProxyServer; import org.littleshoot.proxy.HttpProxyServer; import org.littleshoot.proxy.ProxyAuthorizationHandler; import org.reficio.ws.client.SoapClientException; import org.reficio.ws.client.TransmissionException; import org.reficio.ws.client.core.Security; import org.reficio.ws.client.core.SoapClient; import org.reficio.ws.it.util.ClientBuilder; import org.reficio.ws.server.core.SoapServer; /** * Test SoapServer<->SoapClient communication using HTTPS * * @author Tom Bujok * @since 1.0.0 */ public class HttpProxyHttpsCooperationTest extends AbstractCooperationTest { @Rule public ExpectedException exception = ExpectedException.none(); private final static int PROXY_PORT = 9797; @Before public void initializeServer() { server = SoapServer.builder() .keyStoreUrl(getKeyStoreUrlOne()) .keyStorePassword(getKeyStorePassword()) .httpsPort(HOST_PORT) .build(); server.start(); } @After public void destroyServer() { server.stop(); } public HttpProxyServer initProxy() { HttpProxyServer proxyServer = new DefaultHttpProxyServer(PROXY_PORT); proxyServer.start(true, true); return proxyServer; } @Test public void testService1_httpProxy_defaultProxySetting() throws Exception { HttpProxyServer proxyServer = initProxy(); try { final Security securityContext = Security.builder() .trustStoreUrl(getKeyStoreUrlOne()) .trustStorePassword(getKeyStorePassword()) .build(); verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("https://" + endpointUrl) .endpointSecurity(securityContext) .build(); } }); } finally { proxyServer.stop(); } } @Test public void testService1_httpProxy_directProxy() throws Exception { HttpProxyServer proxyServer = initProxy(); try { final Security securityContext = Security.builder() .trustStoreUrl(getKeyStoreUrlOne()) .trustStorePassword(getKeyStorePassword()) .build(); verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("https://" + endpointUrl) .endpointSecurity(securityContext) .build(); } }); } finally { proxyServer.stop(); } } @Test public void testService1_httpProxy_noAuthentication() throws Exception { HttpProxyServer proxyServer = initProxy(); try { final Security securityContext = Security.builder() .trustStoreUrl(getKeyStoreUrlOne()) .trustStorePassword(getKeyStorePassword()) .build(); verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("https://" + endpointUrl) .proxyUri("http://127.0.0.1:" + PROXY_PORT) .endpointSecurity(securityContext) .build(); } }); } finally { proxyServer.stop(); } } @Test public void testService1_httpProxy_basicAuthentication_success() throws Exception { HttpProxyServer proxyServer = initProxy(); proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() { @Override public boolean authenticate(String user, String pass) { return user.equals("tom") && pass.equals("007"); } }); try { final Security securityContext = Security.builder() .trustStoreUrl(getKeyStoreUrlOne()) .trustStorePassword(getKeyStorePassword()) .build(); final Security security = Security.builder() .authBasic("tom", "007") .build(); verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder() .endpointUri("https://" + endpointUrl) .endpointSecurity(securityContext) .proxyUri("http://127.0.0.1:" + PROXY_PORT) .proxySecurity(security) .build(); } }); } finally { proxyServer.stop(); } } @Test public void testService1_httpProxy_basicAuthentication_wrongKeystore_failure() throws Exception { exception.expect(SoapClientException.class); exception.expectMessage("peer not authenticated"); HttpProxyServer proxyServer = initProxy(); proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() { @Override public boolean authenticate(String user, String pass) { return user.equals("tom") && pass.equals("007"); } }); try { final Security securityContext = Security.builder() .trustStoreUrl(getKeyStoreUrlTwo()) .trustStorePassword(getKeyStorePassword()) .build(); final Security security = Security.builder() .authBasic("tom", "007") .build(); verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder() .endpointUri("https://" + endpointUrl) .endpointSecurity(securityContext) .proxyUri("http://127.0.0.1:" + PROXY_PORT) .proxySecurity(security) .build(); } }); } finally { proxyServer.stop(); } } @Test public void testService1_httpProxy_basicAuthentication_failure() throws Exception { exception.expect(TransmissionException.class); exception.expectMessage("[407]"); HttpProxyServer proxyServer = initProxy(); proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() { @Override public boolean authenticate(String user, String pass) { return user.equals("tom") && pass.equals("007"); } }); final Security props = Security.builder() .authBasic("james", "003") .build(); try { final Security securityContext = Security.builder() .trustStoreUrl(getKeyStoreUrlOne()) .trustStorePassword(getKeyStorePassword()) .build(); verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("https://" + endpointUrl) .proxyUri("http://127.0.0.1:" + PROXY_PORT) .proxySecurity(props) .endpointSecurity(securityContext) .build(); } }); } finally { proxyServer.stop(); } } } ================================================ FILE: soap-it/src/test/java/org/reficio/ws/it/HttpsCooperationTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.it; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.reficio.ws.client.SoapClientException; import org.reficio.ws.client.core.Security; import org.reficio.ws.client.core.SoapClient; import org.reficio.ws.it.util.ClientBuilder; import org.reficio.ws.server.core.SoapServer; import java.net.URL; import java.util.Arrays; import java.util.Collection; /** * Test SoapServer<->SoapClient communication using HTTPS * * @author Tom Bujok * @since 1.0.0 */ @RunWith(Parameterized.class) public class HttpsCooperationTest extends AbstractCooperationTest { private URL keyStoreUrl; @Rule public ExpectedException exception = ExpectedException.none(); public HttpsCooperationTest(URL url) { keyStoreUrl = url; } @Parameterized.Parameters public static Collection keyStores() { return Arrays.asList(new Object[][]{{getKeyStoreUrlOne()}, {getMultiKeyStoreUrl()}}); } @Before public void initializeServer() { server = SoapServer.builder() .keyStoreUrl(keyStoreUrl) .keyStorePassword(getKeyStorePassword()) .httpsPort(HOST_PORT) .build(); server.start(); } @After public void destroyServer() { server.stop(); } @Test public void testService1() throws Exception { verifyServiceBehavior(1, client()); } @Test public void testService2() throws Exception { verifyServiceBehavior(2, client()); } @Test public void testService2_wrongKeyStore_failure() throws Exception { exception.expect(SoapClientException.class); exception.expectMessage("not authenticated"); verifyServiceBehavior(2, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { Security securityContext = Security.builder() .trustStoreUrl(getKeyStoreUrlTwo()) .trustStorePassword(getKeyStorePassword()) .build(); return SoapClient.builder().endpointUri("https://" + endpointUrl) .endpointSecurity(securityContext) .build(); } }); } private class HttpsClientBuilder implements ClientBuilder { @Override public SoapClient buildClient(String endpointUrl) { Security securityContext = Security.builder() .trustStoreUrl(keyStoreUrl) .trustStorePassword(getKeyStorePassword()) .build(); return SoapClient.builder().endpointUri("https://" + endpointUrl) .endpointSecurity(securityContext) .build(); } } private ClientBuilder client() { return new HttpsClientBuilder(); } } ================================================ FILE: soap-it/src/test/java/org/reficio/ws/it/HttpsProxyHttpCooperationTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.it; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.littleshoot.proxy.DefaultHttpProxyServer; import org.littleshoot.proxy.HttpProxyServer; import org.littleshoot.proxy.ProxyAuthorizationHandler; import org.reficio.ws.client.SoapClientException; import org.reficio.ws.client.TransmissionException; import org.reficio.ws.client.core.Security; import org.reficio.ws.client.core.SoapClient; import org.reficio.ws.it.util.ClientBuilder; import org.reficio.ws.it.util.SslTunnel; import org.reficio.ws.server.core.SoapServer; import java.security.KeyStore; /** * Test SoapServer<->SoapClient communication using HTTPS * * @author Tom Bujok * @since 1.0.0 */ public class HttpsProxyHttpCooperationTest extends AbstractCooperationTest { @Rule public ExpectedException exception = ExpectedException.none(); private final static int PROXY_PORT = 9797; @Before public void initializeServer() { server = SoapServer.builder() .httpPort(HOST_PORT) .build(); server.start(); } @After public void destroyServer() { server.stop(); } public HttpProxyServer initProxy() { HttpProxyServer proxyServer = new DefaultHttpProxyServer(PROXY_PORT); proxyServer.start(true, true); return proxyServer; } @Test public void testService1_httpsProxy_defaultProxySetting() throws Exception { HttpProxyServer proxyServer = initProxy(); try { verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("http://" + endpointUrl) .build(); } }); } finally { proxyServer.stop(); } } @Test public void testService1_httpsProxy_directProxy() throws Exception { HttpProxyServer proxyServer = initProxy(); try { verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("http://" + endpointUrl) .build(); } }); } finally { proxyServer.stop(); } } @Test public void testService1_httpsProxy_noAuthentication() throws Exception { KeyStore ks = readKeyStore(getKeyStoreUrlOne(), getKeyStorePassword(), "JKS"); SslTunnel tunnel = new SslTunnel(ks, getKeyStorePassword(), 9898, "localhost", 9797); tunnel.start(); HttpProxyServer proxyServer = initProxy(); try { final Security securityContext = Security.builder() .trustStoreUrl(getKeyStoreUrlOne()) .trustStorePassword(getKeyStorePassword()) .build(); verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("http://" + endpointUrl) .proxyUri("https://127.0.0.1:" + 9898) .proxySecurity(securityContext) .build(); } }); } finally { tunnel.stop(); proxyServer.stop(); } } @Test public void testService1_httpProxy_basicAuthentication_success() throws Exception { KeyStore ks = readKeyStore(getKeyStoreUrlOne(), getKeyStorePassword(), "JKS"); SslTunnel tunnel = new SslTunnel(ks, getKeyStorePassword(), 9898, "localhost", 9797); tunnel.start(); HttpProxyServer proxyServer = initProxy(); proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() { @Override public boolean authenticate(String user, String pass) { return user.equals("tom") && pass.equals("007"); } }); try { final Security security = Security.builder() .authBasic("tom", "007") .trustStoreUrl(getKeyStoreUrlOne()) .trustStorePassword(getKeyStorePassword()) .build(); verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder() .endpointUri("http://" + endpointUrl) .proxyUri("https://127.0.0.1:" + 9898) .proxySecurity(security) .build(); } }); } finally { tunnel.stop(); proxyServer.stop(); } } @Test public void testService1_httpProxy_basicAuthentication_failure() throws Exception { exception.expect(TransmissionException.class); exception.expectMessage("[407]"); KeyStore ks = readKeyStore(getKeyStoreUrlOne(), getKeyStorePassword(), "JKS"); SslTunnel tunnel = new SslTunnel(ks, getKeyStorePassword(), 9898, "localhost", 9797); tunnel.start(); HttpProxyServer proxyServer = initProxy(); proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() { @Override public boolean authenticate(String user, String pass) { return user.equals("tom") && pass.equals("007"); } }); final Security props = Security.builder() .authBasic("james", "003") .trustStoreUrl(getKeyStoreUrlOne()) .trustStorePassword(getKeyStorePassword()) .build(); try { verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("http://" + endpointUrl) .proxyUri("https://127.0.0.1:" + 9898) .proxySecurity(props) .build(); } }); } finally { tunnel.stop(); proxyServer.stop(); } } @Test public void testService1_httpProxy_basicAuthentication_wrongKeystore_failure() throws Exception { exception.expect(SoapClientException.class); exception.expectMessage("peer not authenticated"); KeyStore ks = readKeyStore(getKeyStoreUrlTwo(), getKeyStorePassword(), "JKS"); SslTunnel tunnel = new SslTunnel(ks, getKeyStorePassword(), 9898, "localhost", 9797); tunnel.start(); HttpProxyServer proxyServer = initProxy(); proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() { @Override public boolean authenticate(String user, String pass) { return user.equals("tom") && pass.equals("007"); } }); final Security props = Security.builder() .authBasic("tom", "007") .trustStoreUrl(getKeyStoreUrlOne()) .trustStorePassword(getKeyStorePassword()) .build(); try { verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("http://" + endpointUrl) .proxyUri("https://127.0.0.1:" + 9898) .proxySecurity(props) .build(); } }); } finally { tunnel.stop(); proxyServer.stop(); } } } ================================================ FILE: soap-it/src/test/java/org/reficio/ws/it/HttpsProxyHttpsCooperationTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.it; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.littleshoot.proxy.DefaultHttpProxyServer; import org.littleshoot.proxy.HttpFilter; import org.littleshoot.proxy.HttpProxyServer; import org.littleshoot.proxy.ProxyAuthorizationHandler; import org.reficio.ws.client.TransmissionException; import org.reficio.ws.client.core.Security; import org.reficio.ws.client.core.SoapClient; import org.reficio.ws.it.util.ClientBuilder; import org.reficio.ws.it.util.SslTunnel; import org.reficio.ws.server.core.SoapServer; import java.security.KeyStore; import java.util.HashMap; import java.util.Map; /** * Test SoapServer<->SoapClient communication using HTTPS * * @author Tom Bujok * @since 1.0.0 */ public class HttpsProxyHttpsCooperationTest extends AbstractCooperationTest { @Rule public ExpectedException exception = ExpectedException.none(); private final static int PROXY_PORT = 9797; private final static int PROXY_SSL_PORT = 9898; private SslTunnel tunnel; private HttpProxyServer proxyServer; @Before public void initializeServer() { server = SoapServer.builder() .keyStoreUrl(getKeyStoreUrlOne()) .keyStorePassword(getKeyStorePassword()) .httpsPort(HOST_PORT) .build(); server.start(); tunnel = getProxyTunnel(); tunnel.start(); proxyServer = getProxy(); proxyServer.start(true, true); } @After public void destroyServer() { server.stop(); proxyServer.stop(); tunnel.stop(); try { Thread.sleep(1000); } catch (InterruptedException e) { } } public HttpProxyServer getProxy() { Map filters = new HashMap(); HttpProxyServer proxyServer = new DefaultHttpProxyServer(PROXY_PORT, filters, null, null, null); return proxyServer; } private Security proxySecurity() { Security securityContext = Security.builder() .trustStoreUrl(getKeyStoreUrlTwo()) .trustStorePassword(getKeyStorePassword()) .build(); return securityContext; } private SslTunnel getProxyTunnel() { KeyStore ks = readKeyStore(getKeyStoreUrlTwo(), getKeyStorePassword(), "JKS"); SslTunnel tunnel = new SslTunnel(ks, getKeyStorePassword(), PROXY_SSL_PORT, "localhost", PROXY_PORT); return tunnel; } private Security endpointSecurity() { Security securityContext = Security.builder() .trustStoreUrl(getKeyStoreUrlOne()) .trustStorePassword(getKeyStorePassword()) .build(); return securityContext; } // @Test // public void testService1_httpProxy_defaultProxySetting_noProxy() throws Exception { // verifyServiceBehavior(1, new ClientBuilder() { // @Override // public SoapClient buildClient(String endpointUrl) { // return SoapClient.builder().endpointUri("https://" + endpointUrl) // .endpointSecurity(endpointSecurity()) // .build(); // } // }); // } @Test public void testService1_httpProxy_noAuthentication() throws Exception { verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("https://" + endpointUrl) .endpointSecurity(endpointSecurity()) .proxyUri("https://127.0.0.1:" + PROXY_SSL_PORT) .proxySecurity(proxySecurity()) .build(); } }); } @Test public void testService1_httpsProxy_basicAuthentication_success() throws Exception { proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() { @Override public boolean authenticate(String user, String pass) { return user.equals("tom") && pass.equals("007"); } }); final Security securityContext = Security.builder() .trustStoreUrl(getKeyStoreUrlTwo()) .trustStorePassword(getKeyStorePassword()) .authBasic("tom", "007") .build(); verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("https://" + endpointUrl) .endpointSecurity(endpointSecurity()) .proxyUri("https://127.0.0.1:" + PROXY_SSL_PORT) .proxySecurity(securityContext) .build(); } }); } @Test public void testService1_httpsProxy_basicAuthentication_failure() throws Exception { exception.expect(TransmissionException.class); exception.expectMessage("[407]"); proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() { @Override public boolean authenticate(String user, String pass) { return user.equals("tom") && pass.equals("007"); } }); final Security securityContext = Security.builder() .trustStoreUrl(getKeyStoreUrlTwo()) .trustStorePassword(getKeyStorePassword()) .authBasic("james", "003") .build(); verifyServiceBehavior(1, new ClientBuilder() { @Override public SoapClient buildClient(String endpointUrl) { return SoapClient.builder().endpointUri("https://" + endpointUrl) .endpointSecurity(endpointSecurity()) .proxyUri("https://127.0.0.1:" + PROXY_SSL_PORT) .proxySecurity(securityContext) .build(); } }); } } ================================================ FILE: soap-it/src/test/java/org/reficio/ws/it/util/ClientBuilder.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.it.util; import org.reficio.ws.client.core.SoapClient; /** * @author: Tom Bujok (tom.bujok@gmail.com) *

* Reficio™ - Reestablish your software! * www.reficio.org */ public interface ClientBuilder { SoapClient buildClient(String endpointUrl); } ================================================ FILE: soap-it/src/test/java/org/reficio/ws/it/util/SslTunnel.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.it.util; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.net.ssl.*; import java.io.InputStream; import java.io.OutputStream; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.security.KeyStore; import java.security.SecureRandom; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; /** * @author: Tom Bujok (tom.bujok@gmail.com) *

* Reficio™ - Reestablish your software! * www.reficio.org */ public class SslTunnel { private final static Log log = LogFactory.getLog(SslTunnel.class); private final KeyStore trustStore; private final KeyStore keyStore; private final String keyStorePassword; private final int sourcePort; private final String targetHost; private final int targetPort; private final AtomicBoolean run = new AtomicBoolean(true); private SSLContext sslContext; private ServerSocket socket; private CountDownLatch latch = new CountDownLatch(3); private List clients = new ArrayList(); public SslTunnel(KeyStore keyStore, String keyStorePassword, int sourcePort, String targetHost, int targetPort) { this.trustStore = null; this.keyStore = keyStore; this.keyStorePassword = keyStorePassword; this.sourcePort = sourcePort; this.targetHost = targetHost; this.targetPort = targetPort; } public SslTunnel(KeyStore keyStore, String keyStorePassword, KeyStore trustStore, int sourcePort, String targetHost, int targetPort) { this.trustStore = trustStore; this.keyStore = keyStore; this.keyStorePassword = keyStorePassword; this.sourcePort = sourcePort; this.targetHost = targetHost; this.targetPort = targetPort; } public void start() { try { sslContext = SSLContext.getInstance("SSLv3"); KeyManager[] keyManagers = null; TrustManager[] trustManagers = null; if (keyStore != null) { KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, keyStorePassword.toCharArray()); X509KeyManager defaultKeyManager = (X509KeyManager) keyManagerFactory.getKeyManagers()[0]; keyManagers = new KeyManager[]{defaultKeyManager}; } if (trustStore != null) { TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(trustStore); X509TrustManager defaultTrustManager = (X509TrustManager) trustManagerFactory.getTrustManagers()[0]; trustManagers = new TrustManager[]{defaultTrustManager}; } sslContext.init(keyManagers, trustManagers, new SecureRandom()); SSLServerSocketFactory socketFactory = sslContext.getServerSocketFactory(); socket = socketFactory.createServerSocket(); socket.setReuseAddress(true); socket.bind(new InetSocketAddress(sourcePort)); new ServerThread(socket, run).start(); } catch (Exception ex) { throw new RuntimeException(ex.getMessage(), ex); } } class ServerThread extends Thread { private final ServerSocket server; private final AtomicBoolean run; public ServerThread(ServerSocket server, AtomicBoolean run) { this.server = server; this.run = run; } public void run() { try { server.setSoTimeout(100); } catch (Exception e) { } while (run.get()) { try { Socket client = server.accept(); if (client != null) { clients.add(client); new PipeThread(client, run).start(); } } catch (Exception e) { } } IOUtils.closeQuietly(server); latch.countDown(); } } public void stop() { try { run.set(false); IOUtils.closeQuietly(socket); for(Socket client : clients) { IOUtils.closeQuietly(client); } latch.await(); } catch (Exception ex) { throw new RuntimeException(); } } class PipeThread extends Thread { private final Socket client; private final AtomicBoolean run; public PipeThread(Socket client, AtomicBoolean run) { this.client = client; this.run = run; } public void run() { try { final Socket target = new Socket(targetHost, targetPort); final InputStream ti = target.getInputStream(); final OutputStream to = target.getOutputStream(); target.setSoTimeout(100); final InputStream ci = client.getInputStream(); final OutputStream co = client.getOutputStream(); client.setSoTimeout(100); new Thread() { public void run() { try { while (run.get()) { try { int read = 0; byte[] buffer = new byte[4096]; read = ti.read(buffer); if (read == -1) { break; } co.write(buffer, 0, read); } catch (Exception ex) { } } IOUtils.closeQuietly(client); } finally { latch.countDown(); } } }.start(); new Thread() { public void run() { try { while (run.get()) { try { int read = 0; byte[] buffer = new byte[4096]; read = ci.read(buffer); if (read == -1) { break; } to.write(buffer, 0, read); } catch (Exception ex) { } } } finally { IOUtils.closeQuietly(client); } latch.countDown(); } }.start(); } catch (Exception ex) { latch.countDown(); latch.countDown(); throw new RuntimeException(ex.getMessage(), ex); } } } } ================================================ FILE: soap-it/src/test/java/org/reficio/ws/it/util/TestUtils.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.it.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.reficio.ws.SoapContext; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.core.Wsdl; import org.reficio.ws.common.ResourceUtils; import org.reficio.ws.server.core.SoapServer; import org.reficio.ws.server.responder.AutoResponder; import javax.wsdl.WSDLException; import javax.xml.namespace.QName; import java.net.URL; import static junit.framework.Assert.assertNotNull; /** * Utils used in SoapClient<->Soap Server integration testing * * @author Tom Bujok * @since 1.0.0 */ public class TestUtils { private final static Log log = LogFactory.getLog(TestUtils.class); public static Wsdl createParserForService(int testServiceId) throws WSDLException { String path = getTestServiceFolderPath(testServiceId); URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath(path, "TestService.wsdl"); Wsdl parser = Wsdl.parse(wsdlUrl); assertNotNull(parser); return parser; } public static String formatContextPath(int testServiceId, QName bindingName) { return "/service" + formatServiceId(testServiceId) + "_" + bindingName.getLocalPart(); } public static String getTestServiceFolderPath(int testServiceId) { String testServiceIdString = formatServiceId(testServiceId); return "/services/test" + testServiceIdString; } public static String formatServiceId(int testServiceId) { return (testServiceId < 10) ? "0" + testServiceId : "" + testServiceId; } public static void registerService(SoapServer server, int testServiceId) throws WSDLException { Wsdl parser = TestUtils.createParserForService(testServiceId); registerAutoResponderForAllServiceBindings(server, testServiceId, parser); } public static void registerService(SoapServer server, int testServiceId, Wsdl parser) throws WSDLException { registerAutoResponderForAllServiceBindings(server, testServiceId, parser); } public static void registerAutoResponderForAllServiceBindings(SoapServer server, int testServiceId, Wsdl parser) { for (QName bindingName : parser.getBindings()) { String contextPath = TestUtils.formatContextPath(testServiceId, bindingName); log.info(String.format("Registering auto responder for service [%d] undex context path [%s]", testServiceId, contextPath)); SoapContext context = SoapContext.builder().exampleContent(true).build(); SoapBuilder builder = parser.binding().name(bindingName).find(); server.registerRequestResponder(contextPath, new AutoResponder(builder, context)); } } } ================================================ FILE: soap-it/src/test/resources/keystores/multi-cert-keystore/gen.sh ================================================ #!/bin/bash keytool -genkey -keystore .keystore -alias john -storepass changeit -keypass changeit -dname "CN=John Smith, OU=Development, O=Standard Supplies Inc., L=Anytown, S=North Carolina, C=US" keytool -genkey -keystore .keystore -alias george -storepass changeit -keypass changeit -dname "CN=George Kowalski, OU=Development, O=Standard Supplies Inc., L=Anytown, S=North Carolina, C=US" ================================================ FILE: soap-it/src/test/resources/keystores/single-cert-keystore/gen.sh ================================================ #!/bin/bash keytool -genkey -keystore .keystore_1 -alias john -storepass changeit -keypass changeit -dname "CN=John Smith, OU=Development, O=Standard Supplies Inc., L=Anytown, S=North Carolina, C=US" keytool -genkey -keystore .keystore_2 -alias george -storepass changeit -keypass changeit -dname "CN=George Kowalski, OU=Development, O=Standard Supplies Inc., L=Anytown, S=North Carolina, C=US" ================================================ FILE: soap-it/src/test/resources/log4j.xml ================================================ ================================================ FILE: soap-it/src/test/resources/services/test01/TestService.wsdl ================================================ Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-it/src/test/resources/services/test01/testservice1.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test01/testservice2.xsd ================================================

test test

]]> WorkID is good to h ================================================ FILE: soap-it/src/test/resources/services/test02/TestService.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-it/src/test/resources/services/test02/testservice1.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test02/testservice2.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test03/TestService.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-it/src/test/resources/services/test03/testservice1.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test03/testservice2.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test04/TestService.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-it/src/test/resources/services/test04/testservice1.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test04/testservice2.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test05/TestBinding.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-it/src/test/resources/services/test05/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test05/testservice1.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test05/testservice2.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test06/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test06/wsdls/TestBinding.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-it/src/test/resources/services/test06/wsdls/xsds/sub/testservice2.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test06/wsdls/xsds/testservice1.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test07/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test07/wsdls/TestBinding.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-it/src/test/resources/services/test07/wsdls/xsds/sub/testservice2.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test07/wsdls/xsds/testservice1.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test08/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test08/wsdls/TestBinding.wsdl ================================================ Read page data from Test Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-it/src/test/resources/services/test08/wsdls/testservice2.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test08/wsdls/xsds/testservice1.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test09/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test09/common.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test09/one.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test09/two.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test10/TestService.wsdl ================================================ Read page data from Test Read page data from Test ================================================ FILE: soap-it/src/test/resources/services/test10/testservice1.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test10/testservice2.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test11/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test12/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test13/TestService.wsdl ================================================ doc/lit request wrapper for operation "createLink". (Creates a link between two personas.) The id of the first persona. The id of the second persona. doc/lit response wrapper for operation "createLink". (Creates a link between two personas.) The link that was created. Thrown when an attempt is made to do something without the correct permissions. doc/lit request wrapper for operation "createSocialGroup". (Create a social group.) The id of the group leader. The ids of the members of the group. Whether the group is exclusive. doc/lit response wrapper for operation "createSocialGroup". (Create a social group.) The group that was created. doc/lit request wrapper for operation "addToSocialGroup". (Adds a persona to a social group.) The id of the group to add the persona to. The id of the persona to add to the group. doc/lit response wrapper for operation "addToSocialGroup". (Adds a persona to a social group.) Whether the persona was successfully added. Thrown when trying to add someone to a social group that is exclusive. doc/lit request wrapper for operation "readGroups". (Reads the social groups to which a specified persona belongs.) The id of the persona. doc/lit response wrapper for operation "readGroups". (Reads the social groups to which a specified persona belongs.) The social groups that were read. doc/lit request wrapper for operation "readPersona". (Reads a persona.) The id of the persona to read. doc/lit response wrapper for operation "readPersona". (Reads a persona.) The persona. doc/lit request wrapper for operation "readPersonas". (Reads a set of personas.) The ids of the personas. doc/lit response wrapper for operation "readPersonas". (Reads a set of personas.) The personas. doc/lit request wrapper for operation "storePersona". (Store a persona.) Th e persona to store. doc/lit response wrapper for operation "storePersona". (Store a persona.) doc/lit request wrapper for operation "deletePersona". (Delete a persona.) The id of the persona to delete. doc/lit response wrapper for operation "deletePersona". (Delete a persona.) Whether the persona was successfully deleted. request message for operation "createLink". (Creates a link between two personas.) response message for operation "createLink". (Creates a link between two personas.) Thrown when an attempt is made to do something without the correct permissions. request message for operation "createSocialGroup". (Create a social group.) response message for operation "createSocialGroup". (Create a social group.) request message for operation "addToSocialGroup". (Adds a persona to a social group.) response message for operation "addToSocialGroup". (Adds a persona to a social group.) Thrown when trying to add someone to a social group that is exclusive. request message for operation "readGroups". (Reads the social groups to which a specified persona belongs.) response message for operation "readGroups". (Reads the social groups to which a specified persona belongs.) request message for operation "readPersona". (Reads a persona.) response m essage for operation "readPersona". (Reads a persona.) request message for operation "readPersonas". (Reads a set of personas.) response message for operation "readPersonas". (Reads a set of personas.) request message for operation "storePersona". (Store a persona.) response message for operation "storePersona". (Store a persona.) request message for operation "deletePersona". (Delete a persona.) response message for operation "deletePersona". (Delete a persona.) The linkage service is used to service the data for creating links between personas. This includes links and social groups. Creates a link between two personas. Create a social group. Adds a persona to a social group. Reads the social groups to which a specified persona belongs. The persona services is used to perform actions on the data associated with a persona. Reads a persona. Reads a set of personas. Store a persona. Delete a persona. SOAP Binding for LinkageService SOAP Binding for PersonaService ================================================ FILE: soap-it/src/test/resources/services/test13/chameleon.xsd ================================================ A link between two personas. The id of the first persona. The id of the second persona. A social group. The id of the social group. The ids of the members in the social group. The id of the group leader. Whether the group is exclusive. A name of a persona. ================================================ FILE: soap-it/src/test/resources/services/test14/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test15/TestService.wsdl ================================================ My first service ================================================ FILE: soap-it/src/test/resources/services/test15/stockquote-schema.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test16/TestService.wsdl ================================================ Stock service ================================================ FILE: soap-it/src/test/resources/services/test16/stockquote-schema.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test17/TestService.wsdl ================================================ My first service ================================================ FILE: soap-it/src/test/resources/services/test17/stockquote-schema.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/services/test18/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test19/TestService.wsdl ================================================ My first service ================================================ FILE: soap-it/src/test/resources/services/test20/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test22/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test23/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test25/TestService.wsdl ================================================ Adds two integers. This is a test WebService. ©DNE Online ================================================ FILE: soap-it/src/test/resources/services/test25/info.txt ================================================ http://www.dneonline.com/calculator.asmx?WSDL ================================================ FILE: soap-it/src/test/resources/services/test26/TestService.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/services/test27/TestService.wsdl ================================================ snowboarding-info.com Endorsement Service ================================================ FILE: soap-it/src/test/resources/services/test27/info.txt ================================================ http://www.w3.org/2001/03/14-annotated-WSDL-examples.html not valid WSDL ================================================ FILE: soap-it/src/test/resources/wsdl/doc.literal/stockquote-schema.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/wsdl/doc.literal/stockquote-ws.wsdl ================================================ My first service ================================================ FILE: soap-it/src/test/resources/wsdl/rpc.encoded/friend-ws.wsdl ================================================ ================================================ FILE: soap-it/src/test/resources/wsdl/rpc.encoded/stockquote-schema.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/wsdl/rpc.encoded/stockquote-ws.wsdl ================================================ Stock service ================================================ FILE: soap-it/src/test/resources/wsdl/rpc.literal/stockquote-schema.xsd ================================================ ================================================ FILE: soap-it/src/test/resources/wsdl/rpc.literal/stockquote-ws.wsdl ================================================ Stock service ================================================ FILE: soap-legacy/pom.xml ================================================ 4.0.0 org.reficio soap-legacy bundle soap-legacy - 3rd party inherited code org.reficio soap-ws 1.0.0-SNAPSHOT ../pom.xml GNU Library or Lesser General Public License (LGPL) 2.1 http://www.gnu.org/licenses/lgpl-2.1.html org.reficio soap-common ${project.version} xmlunit xmlunit 1.3 xml-apis xml-apis 1.0.b2 org.apache.xmlgraphics batik-ext 1.7 xerces xercesImpl 2.10.0 xmlbeans xbean fixed-2.4.0 xmlbeans xbean_xpath 2.4.0 org.apache.xmlbeans xmlbeans-xmlpublic 2.5.0 javax.xml jsr173 1.0 net.sf.saxon saxon 9.1.0.8 net.sf.saxon saxon-dom 9.1.0.8 wsrf wsrf-xbeans 1.0 wsdl4j wsdl4j 1.6.2 org.apache.ws.commons.schema XmlSchema com.googlecode.guava-osgi guava-osgi commons-io commons-io org.apache.commons commons-lang3 commons-logging commons-logging log4j log4j junit junit test org.apache.maven.plugins maven-site-plugin 3.1 true org.apache.maven.plugins maven-javadoc-plugin 2.8.1 true ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/AbstractSoapVersion.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.log4j.Logger; import org.apache.xmlbeans.*; import javax.xml.namespace.QName; import java.util.ArrayList; import java.util.List; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. * * Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base */ /** * Common behaviour for all SOAP Versions * * @author ole.matzura */ abstract class AbstractSoapVersion implements SoapVersion { private final static Logger log = Logger.getLogger(AbstractSoapVersion.class); @SuppressWarnings("unchecked") public void validateSoapEnvelope(String soapMessage, List errors) { List errorList = new ArrayList(); try { XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setLoadLineNumbers(); xmlOptions.setValidateTreatLaxAsSkip(); xmlOptions.setLoadLineNumbers(XmlOptions.LOAD_LINE_NUMBERS_END_ELEMENT); XmlObject xmlObject = getSoapEnvelopeSchemaLoader().parse(soapMessage, getEnvelopeType(), xmlOptions); xmlOptions.setErrorListener(errorList); xmlObject.validate(xmlOptions); } catch (XmlException e) { if (e.getErrors() != null) errorList.addAll(e.getErrors()); errors.add(XmlError.forMessage(e.getMessage())); } catch (Exception e) { errors.add(XmlError.forMessage(e.getMessage())); } finally { for (XmlError error : errorList) { if (error instanceof XmlValidationError && shouldIgnore((XmlValidationError) error)) { log.warn("Ignoring validation error: " + error.toString()); continue; } errors.add(error); } } } protected abstract SchemaTypeLoader getSoapEnvelopeSchemaLoader(); public boolean shouldIgnore(XmlValidationError error) { QName offendingQName = error.getOffendingQName(); if (offendingQName != null) { if (offendingQName.equals(new QName(getEnvelopeNamespace(), "encodingStyle"))) { return true; } else if (offendingQName.equals(new QName(getEnvelopeNamespace(), "mustUnderstand"))) { return true; } } return false; } public abstract SchemaType getFaultType(); public abstract SchemaType getEnvelopeType(); } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/Constants.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. * * Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base */ /** * Namespace Constants * * @author ole.matzura */ interface Constants { public static final String XSD_NS = "http://www.w3.org/2001/XMLSchema"; public static final String XML_NS = "http://www.w3.org/2000/xmlns/"; public static final String WSDL11_NS = "http://schemas.xmlsoap.org/wsdl/"; public static final String SOAP_ENCODING_NS = "http://schemas.xmlsoap.org/soap/encoding/"; public static final String SOAP11_ENVELOPE_NS = "http://schemas.xmlsoap.org/soap/envelope/"; public static final String SOAP_HTTP_TRANSPORT = "http://schemas.xmlsoap.org/soap/http"; public static final String SOAP_HTTP_BINDING_NS = "http://schemas.xmlsoap.org/wsdl/soap/"; public static final String SOAP12_HTTP_BINDING_NS = "http://www.w3.org/2003/05/soap/bindings/HTTP/"; public static final String XSI_NS = "http://www.w3.org/2001/XMLSchema-instance"; public static final String XSI_NS_2000 = "http://www.w3.org/2000/XMLSchema-instance"; public static final String SOAP12_ENVELOPE_NS = "http://www.w3.org/2003/05/soap-envelope"; public static final String WADL10_NS = "http://research.sun.com/wadl/2006/10"; public static final String WADL11_NS = "http://wadl.dev.java.net/2009/02"; public static final String SOAP_MICROSOFT_TCP = "http://schemas.microsoft.com/wse/2003/06/tcp"; } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/DefinitionLoader.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. *

* Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base */ interface DefinitionLoader extends SchemaLoader { void setProgressInfo(String info); boolean isAborted(); boolean abort(); void setNewBaseURI(String uri); String getFirstNewURI(); } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/SampleXmlUtil.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.commons.lang3.StringUtils; import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.util.Base64; import org.apache.xmlbeans.impl.util.HexBin; import org.apache.xmlbeans.soap.SOAPArrayType; import org.apache.xmlbeans.soap.SchemaWSDLArrayType; import org.reficio.ws.SoapContext; import org.reficio.ws.SoapMultiValuesProvider; import javax.xml.namespace.QName; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. * * Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base * - introduction of SoapContext class */ /** * XmlBeans class for generating XML from XML Schemas */ class SampleXmlUtil { private Random picker = new Random(1); private boolean soapEnc; private boolean exampleContent = false; private boolean typeComment = false; private boolean skipComments = false; private boolean ignoreOptional = false; /* * A list of XML-Schema types and global elements in the form of name@namespace which * will be excluded when generating sample requests and responses and input forms. * By default the XML-Schema root element is added since it is quite common in .NET * services and generates a sample xml fragment of about 300 kb!. */ private Set excludedTypes = new HashSet(); private SoapMultiValuesProvider multiValuesProvider; private ArrayList typeStack = new ArrayList(); public SampleXmlUtil(boolean soapEnc, SoapContext context) { this.soapEnc = soapEnc; excludedTypes.addAll(context.getExcludedTypes()); this.exampleContent = context.isExampleContent(); this.typeComment = context.isTypeComments(); this.skipComments = !context.isValueComments(); this.ignoreOptional = !context.isBuildOptional(); this.multiValuesProvider = context.getMultiValuesProvider(); } public boolean isSoapEnc() { return soapEnc; } public String createSample(SchemaType sType) { XmlObject object = XmlObject.Factory.newInstance(); XmlCursor cursor = object.newCursor(); // Skip the document node cursor.toNextToken(); // Using the type and the cursor, call the utility method to get a // sample XML payload for that Schema element createSampleForType(sType, cursor); // Cursor now contains the sample payload // Pretty print the result. Note that the cursor is positioned at the // end of the doc so we use the original xml object that the cursor was // created upon to do the xmlText() against. cursor.dispose(); XmlOptions options = new XmlOptions(); options.put(XmlOptions.SAVE_PRETTY_PRINT); options.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3); options.put(XmlOptions.SAVE_AGGRESSIVE_NAMESPACES); options.setSaveOuter(); String result = object.xmlText(options); return result; } /** * Cursor position Before: ^ After: * ^ */ public void createSampleForType(SchemaType stype, XmlCursor xmlc) { QName nm = stype.getName(); if (nm == null && stype.getContainerField() != null) nm = stype.getContainerField().getName(); if (nm != null && excludedTypes.contains(nm)) { if (!skipComments) xmlc.insertComment("Ignoring type [" + nm + "]"); return; } if (typeStack.contains(stype)) return; typeStack.add(stype); try { if (stype.isSimpleType() || stype.isURType()) { processSimpleType(stype, xmlc); return; } // complex Type // ^ processAttributes(stype, xmlc); // ^ switch (stype.getContentType()) { case SchemaType.NOT_COMPLEX_TYPE: case SchemaType.EMPTY_CONTENT: // noop break; case SchemaType.SIMPLE_CONTENT: { processSimpleType(stype, xmlc); } break; case SchemaType.MIXED_CONTENT: xmlc.insertChars(pick(WORDS) + " "); if (stype.getContentModel() != null) { processParticle(stype.getContentModel(), xmlc, true); } xmlc.insertChars(pick(WORDS)); break; case SchemaType.ELEMENT_CONTENT: if (stype.getContentModel() != null) { processParticle(stype.getContentModel(), xmlc, false); } break; } } finally { typeStack.remove(typeStack.size() - 1); } } private void processSimpleType(SchemaType stype, XmlCursor xmlc) { if (soapEnc) { QName typeName = stype.getName(); if (typeName != null) { xmlc.insertAttributeWithValue(XSI_TYPE, formatQName(xmlc, typeName)); } } String sample = sampleDataForSimpleType(stype); xmlc.insertChars(sample); } private String sampleDataForSimpleType(SchemaType sType) { // swaRef if (sType.getName() != null) { if (sType.getName().equals(new QName("http://ws-i.org/profiles/basic/1.1/xsd", "swaRef"))) return "cid:" + (long) (System.currentTimeMillis() * Math.random()); // xmime base64 if (sType.getName().equals(new QName("http://www.w3.org/2005/05/xmlmime", "base64Binary"))) return "cid:" + (long) (System.currentTimeMillis() * Math.random()); // xmime hexBinary if (sType.getName().equals(new QName("http://www.w3.org/2005/05/xmlmime", "hexBinary"))) return "cid:" + (long) (System.currentTimeMillis() * Math.random()); } SchemaType primitiveType = sType.getPrimitiveType(); if (primitiveType != null && (primitiveType.getBuiltinTypeCode() == SchemaType.BTC_BASE_64_BINARY || primitiveType .getBuiltinTypeCode() == SchemaType.BTC_HEX_BINARY)) return "cid:" + (long) (System.currentTimeMillis() * Math.random()); // if( sType != null ) if (!exampleContent) return "?"; if (XmlObject.type.equals(sType)) return "anyType"; if (XmlAnySimpleType.type.equals(sType)) return "anySimpleType"; if (sType.getSimpleVariety() == SchemaType.LIST) { SchemaType itemType = sType.getListItemType(); StringBuffer sb = new StringBuffer(); int length = pickLength(sType); if (length > 0) sb.append(sampleDataForSimpleType(itemType)); for (int i = 1; i < length; i += 1) { sb.append(' '); sb.append(sampleDataForSimpleType(itemType)); } return sb.toString(); } if (sType.getSimpleVariety() == SchemaType.UNION) { SchemaType[] possibleTypes = sType.getUnionConstituentTypes(); if (possibleTypes.length == 0) return ""; return sampleDataForSimpleType(possibleTypes[pick(possibleTypes.length)]); } XmlAnySimpleType[] enumValues = sType.getEnumerationValues(); if (enumValues != null && enumValues.length > 0) { return enumValues[pick(enumValues.length)].getStringValue(); } switch (primitiveType.getBuiltinTypeCode()) { default: case SchemaType.BTC_NOT_BUILTIN: return ""; case SchemaType.BTC_ANY_TYPE: case SchemaType.BTC_ANY_SIMPLE: return "anything"; case SchemaType.BTC_BOOLEAN: return pick(2) == 0 ? "true" : "false"; case SchemaType.BTC_BASE_64_BINARY: { String result = null; try { result = new String(Base64.encode(formatToLength(pick(WORDS), sType).getBytes("utf-8"))); } catch (java.io.UnsupportedEncodingException e) { } return result; } case SchemaType.BTC_HEX_BINARY: return HexBin.encode(formatToLength(pick(WORDS), sType)); case SchemaType.BTC_ANY_URI: return formatToLength("http://www." + pick(DNS1) + "." + pick(DNS2) + "/" + pick(WORDS) + "/" + pick(WORDS), sType); case SchemaType.BTC_QNAME: return formatToLength("qname", sType); case SchemaType.BTC_NOTATION: return formatToLength("notation", sType); case SchemaType.BTC_FLOAT: return "1.25"; // return Float.valueOf(new Random().nextFloat()).toString(); case SchemaType.BTC_DOUBLE: return "1.30"; // return Double.valueOf(new Random().nextDouble()).toString(); case SchemaType.BTC_DECIMAL: switch (closestBuiltin(sType).getBuiltinTypeCode()) { case SchemaType.BTC_SHORT: return formatDecimal("1", sType); case SchemaType.BTC_UNSIGNED_SHORT: return formatDecimal("5", sType); case SchemaType.BTC_BYTE: return formatDecimal("2", sType); case SchemaType.BTC_UNSIGNED_BYTE: return formatDecimal("6", sType); case SchemaType.BTC_INT: return formatDecimal("3", sType); case SchemaType.BTC_UNSIGNED_INT: return formatDecimal("7", sType); case SchemaType.BTC_LONG: return formatDecimal("10", sType); case SchemaType.BTC_UNSIGNED_LONG: return formatDecimal("11", sType); case SchemaType.BTC_INTEGER: return formatDecimal("100", sType); case SchemaType.BTC_NON_POSITIVE_INTEGER: return formatDecimal("-200", sType); case SchemaType.BTC_NEGATIVE_INTEGER: return formatDecimal("-201", sType); case SchemaType.BTC_NON_NEGATIVE_INTEGER: return formatDecimal("200", sType); case SchemaType.BTC_POSITIVE_INTEGER: return formatDecimal("201", sType); default: case SchemaType.BTC_DECIMAL: return formatDecimal("1000.00", sType); } case SchemaType.BTC_STRING: { String result; switch (closestBuiltin(sType).getBuiltinTypeCode()) { case SchemaType.BTC_STRING: case SchemaType.BTC_NORMALIZED_STRING: result = pick(WORDS, picker.nextInt(3)); break; case SchemaType.BTC_TOKEN: result = pick(WORDS, picker.nextInt(3)); break; default: result = pick(WORDS, picker.nextInt(3)); break; } return formatToLength(result, sType); } case SchemaType.BTC_DURATION: return formatDuration(sType); case SchemaType.BTC_DATE_TIME: case SchemaType.BTC_TIME: case SchemaType.BTC_DATE: case SchemaType.BTC_G_YEAR_MONTH: case SchemaType.BTC_G_YEAR: case SchemaType.BTC_G_MONTH_DAY: case SchemaType.BTC_G_DAY: case SchemaType.BTC_G_MONTH: return formatDate(sType); } } // a bit from the Aenid public static final String[] WORDS = new String[]{"ipsa", "iovis", "rapidum", "iaculata", "e", "nubibus", "ignem", "disiecitque", "rates", "evertitque", "aequora", "ventis", "illum", "exspirantem", "transfixo", "pectore", "flammas", "turbine", "corripuit", "scopuloque", "infixit", "acuto", "ast", "ego", "quae", "divum", "incedo", "regina", "iovisque", "et", "soror", "et", "coniunx", "una", "cum", "gente", "tot", "annos", "bella", "gero", "et", "quisquam", "numen", "iunonis", "adorat", "praeterea", "aut", "supplex", "aris", "imponet", "honorem", "talia", "flammato", "secum", "dea", "corde", "volutans", "nimborum", "in", "patriam", "loca", "feta", "furentibus", "austris", "aeoliam", "venit", "hic", "vasto", "rex", "aeolus", "antro", "luctantis", "ventos", "tempestatesque", "sonoras", "imperio", "premit", "ac", "vinclis", "et", "carcere", "frenat", "illi", "indignantes", "magno", "cum", "murmure", "montis", "circum", "claustra", "fremunt", "celsa", "sedet", "aeolus", "arce", "sceptra", "tenens", "mollitque", "animos", "et", "temperat", "iras", "ni", "faciat", "maria", "ac", "terras", "caelumque", "profundum", "quippe", "ferant", "rapidi", "secum", "verrantque", "per", "auras", "sed", "pater", "omnipotens", "speluncis", "abdidit", "atris", "hoc", "metuens", "molemque", "et", "montis", "insuper", "altos", "imposuit", "regemque", "dedit", "qui", "foedere", "certo", "et", "premere", "et", "laxas", "sciret", "dare", "iussus", "habenas",}; private static final String[] DNS1 = new String[]{"corp", "your", "my", "sample", "company", "test", "any"}; private static final String[] DNS2 = new String[]{"com", "org", "com", "gov", "org", "com", "org", "com", "edu"}; private int pick(int n) { return picker.nextInt(n); } private String pick(String[] a) { return a[pick(a.length)]; } private String pick(String[] a, int count) { if (count <= 0) count = 1; // return ""; int i = pick(a.length); StringBuffer sb = new StringBuffer(a[i]); while (count-- > 0) { i += 1; if (i >= a.length) i = 0; sb.append(' '); sb.append(a[i]); } return sb.toString(); } @SuppressWarnings("unused") private String pickDigits(int digits) { StringBuffer sb = new StringBuffer(); while (digits-- > 0) sb.append(Integer.toString(pick(10))); return sb.toString(); } private int pickLength(SchemaType sType) { XmlInteger length = (XmlInteger) sType.getFacet(SchemaType.FACET_LENGTH); if (length != null) return length.getBigIntegerValue().intValue(); XmlInteger min = (XmlInteger) sType.getFacet(SchemaType.FACET_MIN_LENGTH); XmlInteger max = (XmlInteger) sType.getFacet(SchemaType.FACET_MAX_LENGTH); int minInt, maxInt; if (min == null) minInt = 0; else minInt = min.getBigIntegerValue().intValue(); if (max == null) maxInt = Integer.MAX_VALUE; else maxInt = max.getBigIntegerValue().intValue(); // We try to keep the length of the array within reasonable limits, // at least 1 item and at most 3 if possible if (minInt == 0 && maxInt >= 1) minInt = 1; if (maxInt > minInt + 2) maxInt = minInt + 2; if (maxInt < minInt) maxInt = minInt; return minInt + pick(maxInt - minInt); } /** * Formats a given string to the required length, using the following * operations: - append the source string to itself as necessary to pass the * minLength; - truncate the result of previous step, if necessary, to keep * it within minLength. */ private String formatToLength(String s, SchemaType sType) { String result = s; try { SimpleValue min = (SimpleValue) sType.getFacet(SchemaType.FACET_LENGTH); if (min == null) min = (SimpleValue) sType.getFacet(SchemaType.FACET_MIN_LENGTH); if (min != null) { int len = min.getIntValue(); while (result.length() < len) result = result + result; } SimpleValue max = (SimpleValue) sType.getFacet(SchemaType.FACET_LENGTH); if (max == null) max = (SimpleValue) sType.getFacet(SchemaType.FACET_MAX_LENGTH); if (max != null) { int len = max.getIntValue(); if (result.length() > len) result = result.substring(0, len); } } catch (Exception e) // intValue can be out of range { } return result; } private String formatDecimal(String start, SchemaType sType) { BigDecimal result = new BigDecimal(start); XmlDecimal xmlD; xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); BigDecimal min = xmlD != null ? xmlD.getBigDecimalValue() : null; xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); BigDecimal max = xmlD != null ? xmlD.getBigDecimalValue() : null; boolean minInclusive = true, maxInclusive = true; xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (xmlD != null) { BigDecimal minExcl = xmlD.getBigDecimalValue(); if (min == null || min.compareTo(minExcl) < 0) { min = minExcl; minInclusive = false; } } xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (xmlD != null) { BigDecimal maxExcl = xmlD.getBigDecimalValue(); if (max == null || max.compareTo(maxExcl) > 0) { max = maxExcl; maxInclusive = false; } } xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_TOTAL_DIGITS); int totalDigits = -1; if (xmlD != null) { totalDigits = xmlD.getBigDecimalValue().intValue(); StringBuffer sb = new StringBuffer(totalDigits); for (int i = 0; i < totalDigits; i++) sb.append('9'); BigDecimal digitsLimit = new BigDecimal(sb.toString()); if (max != null && max.compareTo(digitsLimit) > 0) { max = digitsLimit; maxInclusive = true; } digitsLimit = digitsLimit.negate(); if (min != null && min.compareTo(digitsLimit) < 0) { min = digitsLimit; minInclusive = true; } } int sigMin = min == null ? 1 : result.compareTo(min); int sigMax = max == null ? -1 : result.compareTo(max); boolean minOk = sigMin > 0 || sigMin == 0 && minInclusive; boolean maxOk = sigMax < 0 || sigMax == 0 && maxInclusive; // Compute the minimum increment xmlD = (XmlDecimal) sType.getFacet(SchemaType.FACET_FRACTION_DIGITS); int fractionDigits = -1; BigDecimal increment; if (xmlD == null) increment = new BigDecimal(1); else { fractionDigits = xmlD.getBigDecimalValue().intValue(); if (fractionDigits > 0) { StringBuffer sb = new StringBuffer("0."); for (int i = 1; i < fractionDigits; i++) sb.append('0'); sb.append('1'); increment = new BigDecimal(sb.toString()); } else increment = new BigDecimal(1); } if (minOk && maxOk) { // OK } else if (minOk && !maxOk) { // TOO BIG if (maxInclusive) result = max; else result = max.subtract(increment); } else if (!minOk && maxOk) { // TOO SMALL if (minInclusive) result = min; else result = min.add(increment); } else { // MIN > MAX!! } // We have the number // Adjust the scale according to the totalDigits and fractionDigits int digits = 0; BigDecimal ONE = new BigDecimal(BigInteger.ONE); for (BigDecimal n = result; n.abs().compareTo(ONE) >= 0; digits++) n = n.movePointLeft(1); if (fractionDigits > 0) if (totalDigits >= 0) result.setScale(Math.max(fractionDigits, totalDigits - digits)); else result.setScale(fractionDigits); else if (fractionDigits == 0) result.setScale(0); return result.toString(); } private String formatDuration(SchemaType sType) { XmlDuration d = (XmlDuration) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); GDuration minInclusive = null; if (d != null) minInclusive = d.getGDurationValue(); d = (XmlDuration) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); GDuration maxInclusive = null; if (d != null) maxInclusive = d.getGDurationValue(); d = (XmlDuration) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); GDuration minExclusive = null; if (d != null) minExclusive = d.getGDurationValue(); d = (XmlDuration) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); GDuration maxExclusive = null; if (d != null) maxExclusive = d.getGDurationValue(); GDurationBuilder gdurb = new GDurationBuilder(); @SuppressWarnings("unused") BigInteger min, max; gdurb.setSecond(pick(800000)); gdurb.setMonth(pick(20)); // Years // Months // Days // Hours // Minutes // Seconds // Fractions if (minInclusive != null) { if (gdurb.getYear() < minInclusive.getYear()) gdurb.setYear(minInclusive.getYear()); if (gdurb.getMonth() < minInclusive.getMonth()) gdurb.setMonth(minInclusive.getMonth()); if (gdurb.getDay() < minInclusive.getDay()) gdurb.setDay(minInclusive.getDay()); if (gdurb.getHour() < minInclusive.getHour()) gdurb.setHour(minInclusive.getHour()); if (gdurb.getMinute() < minInclusive.getMinute()) gdurb.setMinute(minInclusive.getMinute()); if (gdurb.getSecond() < minInclusive.getSecond()) gdurb.setSecond(minInclusive.getSecond()); if (gdurb.getFraction().compareTo(minInclusive.getFraction()) < 0) gdurb.setFraction(minInclusive.getFraction()); } if (maxInclusive != null) { if (gdurb.getYear() > maxInclusive.getYear()) gdurb.setYear(maxInclusive.getYear()); if (gdurb.getMonth() > maxInclusive.getMonth()) gdurb.setMonth(maxInclusive.getMonth()); if (gdurb.getDay() > maxInclusive.getDay()) gdurb.setDay(maxInclusive.getDay()); if (gdurb.getHour() > maxInclusive.getHour()) gdurb.setHour(maxInclusive.getHour()); if (gdurb.getMinute() > maxInclusive.getMinute()) gdurb.setMinute(maxInclusive.getMinute()); if (gdurb.getSecond() > maxInclusive.getSecond()) gdurb.setSecond(maxInclusive.getSecond()); if (gdurb.getFraction().compareTo(maxInclusive.getFraction()) > 0) gdurb.setFraction(maxInclusive.getFraction()); } if (minExclusive != null) { if (gdurb.getYear() <= minExclusive.getYear()) gdurb.setYear(minExclusive.getYear() + 1); if (gdurb.getMonth() <= minExclusive.getMonth()) gdurb.setMonth(minExclusive.getMonth() + 1); if (gdurb.getDay() <= minExclusive.getDay()) gdurb.setDay(minExclusive.getDay() + 1); if (gdurb.getHour() <= minExclusive.getHour()) gdurb.setHour(minExclusive.getHour() + 1); if (gdurb.getMinute() <= minExclusive.getMinute()) gdurb.setMinute(minExclusive.getMinute() + 1); if (gdurb.getSecond() <= minExclusive.getSecond()) gdurb.setSecond(minExclusive.getSecond() + 1); if (gdurb.getFraction().compareTo(minExclusive.getFraction()) <= 0) gdurb.setFraction(minExclusive.getFraction().add(new BigDecimal(0.001))); } if (maxExclusive != null) { if (gdurb.getYear() > maxExclusive.getYear()) gdurb.setYear(maxExclusive.getYear()); if (gdurb.getMonth() > maxExclusive.getMonth()) gdurb.setMonth(maxExclusive.getMonth()); if (gdurb.getDay() > maxExclusive.getDay()) gdurb.setDay(maxExclusive.getDay()); if (gdurb.getHour() > maxExclusive.getHour()) gdurb.setHour(maxExclusive.getHour()); if (gdurb.getMinute() > maxExclusive.getMinute()) gdurb.setMinute(maxExclusive.getMinute()); if (gdurb.getSecond() > maxExclusive.getSecond()) gdurb.setSecond(maxExclusive.getSecond()); if (gdurb.getFraction().compareTo(maxExclusive.getFraction()) > 0) gdurb.setFraction(maxExclusive.getFraction()); } gdurb.normalize(); return gdurb.toString(); } private String formatDate(SchemaType sType) { GDateBuilder gdateb = new GDateBuilder(new Date(1000L * pick(365 * 24 * 60 * 60) + (30L + pick(20)) * 365 * 24 * 60 * 60 * 1000)); GDate min = null, max = null; // Find the min and the max according to the type switch (sType.getPrimitiveType().getBuiltinTypeCode()) { case SchemaType.BTC_DATE_TIME: { XmlDateTime x = (XmlDateTime) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); if (x != null) min = x.getGDateValue(); x = (XmlDateTime) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (x != null) if (min == null || min.compareToGDate(x.getGDateValue()) <= 0) min = x.getGDateValue(); x = (XmlDateTime) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); if (x != null) max = x.getGDateValue(); x = (XmlDateTime) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (x != null) if (max == null || max.compareToGDate(x.getGDateValue()) >= 0) max = x.getGDateValue(); break; } case SchemaType.BTC_TIME: { XmlTime x = (XmlTime) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); if (x != null) min = x.getGDateValue(); x = (XmlTime) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (x != null) if (min == null || min.compareToGDate(x.getGDateValue()) <= 0) min = x.getGDateValue(); x = (XmlTime) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); if (x != null) max = x.getGDateValue(); x = (XmlTime) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (x != null) if (max == null || max.compareToGDate(x.getGDateValue()) >= 0) max = x.getGDateValue(); break; } case SchemaType.BTC_DATE: { XmlDate x = (XmlDate) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); if (x != null) min = x.getGDateValue(); x = (XmlDate) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (x != null) if (min == null || min.compareToGDate(x.getGDateValue()) <= 0) min = x.getGDateValue(); x = (XmlDate) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); if (x != null) max = x.getGDateValue(); x = (XmlDate) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (x != null) if (max == null || max.compareToGDate(x.getGDateValue()) >= 0) max = x.getGDateValue(); break; } case SchemaType.BTC_G_YEAR_MONTH: { XmlGYearMonth x = (XmlGYearMonth) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); if (x != null) min = x.getGDateValue(); x = (XmlGYearMonth) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (x != null) if (min == null || min.compareToGDate(x.getGDateValue()) <= 0) min = x.getGDateValue(); x = (XmlGYearMonth) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); if (x != null) max = x.getGDateValue(); x = (XmlGYearMonth) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (x != null) if (max == null || max.compareToGDate(x.getGDateValue()) >= 0) max = x.getGDateValue(); break; } case SchemaType.BTC_G_YEAR: { XmlGYear x = (XmlGYear) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); if (x != null) min = x.getGDateValue(); x = (XmlGYear) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (x != null) if (min == null || min.compareToGDate(x.getGDateValue()) <= 0) min = x.getGDateValue(); x = (XmlGYear) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); if (x != null) max = x.getGDateValue(); x = (XmlGYear) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (x != null) if (max == null || max.compareToGDate(x.getGDateValue()) >= 0) max = x.getGDateValue(); break; } case SchemaType.BTC_G_MONTH_DAY: { XmlGMonthDay x = (XmlGMonthDay) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); if (x != null) min = x.getGDateValue(); x = (XmlGMonthDay) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (x != null) if (min == null || min.compareToGDate(x.getGDateValue()) <= 0) min = x.getGDateValue(); x = (XmlGMonthDay) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); if (x != null) max = x.getGDateValue(); x = (XmlGMonthDay) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (x != null) if (max == null || max.compareToGDate(x.getGDateValue()) >= 0) max = x.getGDateValue(); break; } case SchemaType.BTC_G_DAY: { XmlGDay x = (XmlGDay) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); if (x != null) min = x.getGDateValue(); x = (XmlGDay) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (x != null) if (min == null || min.compareToGDate(x.getGDateValue()) <= 0) min = x.getGDateValue(); x = (XmlGDay) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); if (x != null) max = x.getGDateValue(); x = (XmlGDay) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (x != null) if (max == null || max.compareToGDate(x.getGDateValue()) >= 0) max = x.getGDateValue(); break; } case SchemaType.BTC_G_MONTH: { XmlGMonth x = (XmlGMonth) sType.getFacet(SchemaType.FACET_MIN_INCLUSIVE); if (x != null) min = x.getGDateValue(); x = (XmlGMonth) sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE); if (x != null) if (min == null || min.compareToGDate(x.getGDateValue()) <= 0) min = x.getGDateValue(); x = (XmlGMonth) sType.getFacet(SchemaType.FACET_MAX_INCLUSIVE); if (x != null) max = x.getGDateValue(); x = (XmlGMonth) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE); if (x != null) if (max == null || max.compareToGDate(x.getGDateValue()) >= 0) max = x.getGDateValue(); break; } } if (min != null && max == null) { if (min.compareToGDate(gdateb) >= 0) { // Reset the date to min + (1-8) hours Calendar c = gdateb.getCalendar(); c.add(Calendar.HOUR_OF_DAY, pick(8)); gdateb = new GDateBuilder(c); } } else if (min == null && max != null) { if (max.compareToGDate(gdateb) <= 0) { // Reset the date to max - (1-8) hours Calendar c = gdateb.getCalendar(); c.add(Calendar.HOUR_OF_DAY, 0 - pick(8)); gdateb = new GDateBuilder(c); } } else if (min != null && max != null) { if (min.compareToGDate(gdateb) >= 0 || max.compareToGDate(gdateb) <= 0) { // Find a date between the two Calendar c = min.getCalendar(); Calendar cmax = max.getCalendar(); c.add(Calendar.HOUR_OF_DAY, 1); if (c.after(cmax)) { c.add(Calendar.HOUR_OF_DAY, -1); c.add(Calendar.MINUTE, 1); if (c.after(cmax)) { c.add(Calendar.MINUTE, -1); c.add(Calendar.SECOND, 1); if (c.after(cmax)) { c.add(Calendar.SECOND, -1); c.add(Calendar.MILLISECOND, 1); if (c.after(cmax)) c.add(Calendar.MILLISECOND, -1); } } } gdateb = new GDateBuilder(c); } } gdateb.setBuiltinTypeCode(sType.getPrimitiveType().getBuiltinTypeCode()); if (pick(2) == 0) gdateb.clearTimeZone(); return gdateb.toString(); } private SchemaType closestBuiltin(SchemaType sType) { while (!sType.isBuiltinType()) sType = sType.getBaseType(); return sType; } /** * Cracks a combined QName of the form URL:localname */ public static QName crackQName(String qName) { String ns; String name; int index = qName.lastIndexOf(':'); if (index >= 0) { ns = qName.substring(0, index); name = qName.substring(index + 1); } else { ns = ""; name = qName; } return new QName(ns, name); } /** * Cursor position: Before this call: ^ (cursor at the * ^) After this call: <som text^ */ private void processParticle(SchemaParticle sp, XmlCursor xmlc, boolean mixed) { int loop = determineMinMaxForSample(sp, xmlc); while (loop-- > 0) { switch (sp.getParticleType()) { case (SchemaParticle.ELEMENT): processElement(sp, xmlc, mixed); break; case (SchemaParticle.SEQUENCE): processSequence(sp, xmlc, mixed); break; case (SchemaParticle.CHOICE): processChoice(sp, xmlc, mixed); break; case (SchemaParticle.ALL): processAll(sp, xmlc, mixed); break; case (SchemaParticle.WILDCARD): processWildCard(sp, xmlc, mixed); break; default: // throw new Exception("No Match on Schema Particle Type: " + // String.valueOf(sp.getParticleType())); } } } private int determineMinMaxForSample(SchemaParticle sp, XmlCursor xmlc) { int minOccurs = sp.getIntMinOccurs(); int maxOccurs = sp.getIntMaxOccurs(); if (minOccurs == maxOccurs) return minOccurs; if (minOccurs == 0 && ignoreOptional) return 0; int result = minOccurs; if (result == 0) result = 1; if (sp.getParticleType() != SchemaParticle.ELEMENT) return result; // it probably only makes sense to put comments in front of individual // elements that repeat if (!skipComments) { if (sp.getMaxOccurs() == null) { // xmlc.insertComment("The next " + getItemNameOrType(sp, xmlc) + " // may // be repeated " + minOccurs + " or more times"); if (minOccurs == 0) xmlc.insertComment("Zero or more repetitions:"); else xmlc.insertComment(minOccurs + " or more repetitions:"); } else if (sp.getIntMaxOccurs() > 1) { xmlc.insertComment(minOccurs + " to " + String.valueOf(sp.getMaxOccurs()) + " repetitions:"); } else { xmlc.insertComment("Optional:"); } } return result; } /* * Return a name for the element or the particle type to use in the comment * for minoccurs, max occurs */ @SuppressWarnings("unused") private String getItemNameOrType(SchemaParticle sp, XmlCursor xmlc) { String elementOrTypeName = null; if (sp.getParticleType() == SchemaParticle.ELEMENT) { elementOrTypeName = "Element (" + sp.getName().getLocalPart() + ")"; } else { elementOrTypeName = printParticleType(sp.getParticleType()); } return elementOrTypeName; } private void processElement(SchemaParticle sp, XmlCursor xmlc, boolean mixed) { // cast as schema local element SchemaLocalElement element = (SchemaLocalElement) sp; // Add comment about type addElementTypeAndRestricionsComment(element, xmlc); // / ^ -> ^ if (soapEnc) xmlc.insertElement(element.getName().getLocalPart()); // test // encoded? // drop // namespaces. else xmlc.insertElement(element.getName().getLocalPart(), element.getName().getNamespaceURI()); // / -> ^ // processAttributes( sp.getType(), xmlc ); xmlc.toPrevToken(); // -> stuff^ String[] values = null; if (multiValuesProvider != null) values = multiValuesProvider.getMultiValues(element.getName()).toArray(new String[]{}); if (values != null) xmlc.insertChars(StringUtils.join(values, "s")); else if (sp.isDefault()) xmlc.insertChars(sp.getDefaultText()); else createSampleForType(element.getType(), xmlc); // -> stuff^ xmlc.toNextToken(); } @SuppressWarnings("unused") private void moveToken(int numToMove, XmlCursor xmlc) { for (int i = 0; i < Math.abs(numToMove); i++) { if (numToMove < 0) { xmlc.toPrevToken(); } else { xmlc.toNextToken(); } } } private static final String formatQName(XmlCursor xmlc, QName qName) { XmlCursor parent = xmlc.newCursor(); parent.toParent(); String prefix = parent.prefixForNamespace(qName.getNamespaceURI()); parent.dispose(); String name; if (prefix == null || prefix.length() == 0) name = qName.getLocalPart(); else name = prefix + ":" + qName.getLocalPart(); return name; } private static final QName HREF = new QName("href"); private static final QName ID = new QName("id"); public static final QName XSI_TYPE = new QName("http://www.w3.org/2001/XMLSchema-instance", "type"); public static final QName ENC_ARRAYTYPE = new QName("http://schemas.xmlsoap.org/soap/encoding/", "arrayType"); private static final QName ENC_OFFSET = new QName("http://schemas.xmlsoap.org/s/encoding/", "offset"); public static final Set SKIPPED_SOAP_ATTRS = new HashSet(Arrays.asList(new QName[]{HREF, ID, ENC_OFFSET})); private void processAttributes(SchemaType stype, XmlCursor xmlc) { if (soapEnc) { QName typeName = stype.getName(); if (typeName != null) { xmlc.insertAttributeWithValue(XSI_TYPE, formatQName(xmlc, typeName)); } } SchemaProperty[] attrProps = stype.getAttributeProperties(); for (int i = 0; i < attrProps.length; i++) { SchemaProperty attr = attrProps[i]; if (attr.getMinOccurs().intValue() == 0 && ignoreOptional) continue; if (attr.getName().equals(new QName("http://www.w3.org/2005/05/xmlmime", "contentType"))) { xmlc.insertAttributeWithValue(attr.getName(), "application/?"); continue; } if (soapEnc) { if (SKIPPED_SOAP_ATTRS.contains(attr.getName())) continue; if (ENC_ARRAYTYPE.equals(attr.getName())) { SOAPArrayType arrayType = ((SchemaWSDLArrayType) stype.getAttributeModel().getAttribute( attr.getName())).getWSDLArrayType(); if (arrayType != null) xmlc.insertAttributeWithValue(attr.getName(), formatQName(xmlc, arrayType.getQName()) + arrayType.soap11DimensionString()); continue; } } String value = null; if (multiValuesProvider != null) { String[] values = multiValuesProvider.getMultiValues(attr.getName()).toArray(new String[]{}); if (values != null) value = StringUtils.join(values, ","); } if (value == null) value = attr.getDefaultText(); if (value == null) value = sampleDataForSimpleType(attr.getType()); xmlc.insertAttributeWithValue(attr.getName(), value); } } private void processSequence(SchemaParticle sp, XmlCursor xmlc, boolean mixed) { SchemaParticle[] spc = sp.getParticleChildren(); for (int i = 0; i < spc.length; i++) { // / maybestuff^ processParticle(spc[i], xmlc, mixed); // maybestuff...morestuff^ if (mixed && i < spc.length - 1) xmlc.insertChars(pick(WORDS)); } } private void processChoice(SchemaParticle sp, XmlCursor xmlc, boolean mixed) { SchemaParticle[] spc = sp.getParticleChildren(); if (!skipComments) xmlc.insertComment("You have a CHOICE of the next " + String.valueOf(spc.length) + " items at this level"); for (int i = 0; i < spc.length; i++) { processParticle(spc[i], xmlc, mixed); } } private void processAll(SchemaParticle sp, XmlCursor xmlc, boolean mixed) { SchemaParticle[] spc = sp.getParticleChildren(); if (!skipComments) xmlc.insertComment("You may enter the following " + String.valueOf(spc.length) + " items in any order"); for (int i = 0; i < spc.length; i++) { processParticle(spc[i], xmlc, mixed); if (mixed && i < spc.length - 1) xmlc.insertChars(pick(WORDS)); } } private void processWildCard(SchemaParticle sp, XmlCursor xmlc, boolean mixed) { if (!skipComments) xmlc.insertComment("You may enter ANY elements at this point"); // xmlc.insertElement("AnyElement"); } /** * This method will get the base type for the schema type */ @SuppressWarnings("unused") private static QName getClosestName(SchemaType sType) { while (sType.getName() == null) sType = sType.getBaseType(); return sType.getName(); } private String printParticleType(int particleType) { StringBuffer returnParticleType = new StringBuffer(); returnParticleType.append("Schema Particle Type: "); switch (particleType) { case SchemaParticle.ALL: returnParticleType.append("ALL\n"); break; case SchemaParticle.CHOICE: returnParticleType.append("CHOICE\n"); break; case SchemaParticle.ELEMENT: returnParticleType.append("ELEMENT\n"); break; case SchemaParticle.SEQUENCE: returnParticleType.append("SEQUENCE\n"); break; case SchemaParticle.WILDCARD: returnParticleType.append("WILDCARD\n"); break; default: returnParticleType.append("Schema Particle Type Unknown"); break; } return returnParticleType.toString(); } private void addElementTypeAndRestricionsComment(SchemaLocalElement element, XmlCursor xmlc) { SchemaType type = element.getType(); if (typeComment && (type != null && type.isSimpleType())) { String info = ""; XmlAnySimpleType[] values = type.getEnumerationValues(); if (values != null && values.length > 0) { info = " - enumeration: ["; for (int c = 0; c < values.length; c++) { if (c > 0) info += ","; info += values[c].getStringValue(); } info += "]"; } if (type.isAnonymousType()) xmlc.insertComment("anonymous type" + info); else xmlc.insertComment("type: " + type.getName().getLocalPart() + info); } } public void setTypeComment(boolean b) { typeComment = b; } public void setIgnoreOptional(boolean b) { ignoreOptional = b; } } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/SchemaDefinitionWrapper.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.xmlbeans.SchemaType; import org.apache.xmlbeans.SchemaTypeLoader; import org.apache.xmlbeans.SchemaTypeSystem; import org.apache.xmlbeans.XmlBeans; import javax.wsdl.Definition; import javax.xml.namespace.QName; import java.util.Collection; import java.util.HashSet; import java.util.Set; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. *

* Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base */ class SchemaDefinitionWrapper { private SchemaTypeSystem schemaTypes; private SchemaTypeLoader schemaTypeLoader; private Definition definition; public SchemaDefinitionWrapper(Definition definition, String schemaURL) { this.definition = definition; loadSchemaTypes(new UrlSchemaLoader(schemaURL)); } public SchemaTypeLoader getSchemaTypeLoader() { return schemaTypeLoader; } public SchemaTypeSystem getSchemaTypeSystem() { return schemaTypes; } public boolean hasSchemaTypes() { return schemaTypes != null; } public Collection getDefinedNamespaces() throws Exception { Set namespaces = new HashSet(); SchemaTypeSystem schemaTypes = getSchemaTypeSystem(); if (schemaTypes != null) { namespaces.addAll(SchemaUtils.extractNamespaces(getSchemaTypeSystem(), true)); } namespaces.add(getTargetNamespace()); return namespaces; } public String getTargetNamespace() { return WsdlUtils.getTargetNamespace(definition); } public SchemaType findType(QName typeName) { return getSchemaTypeLoader().findType(typeName); } public void loadSchemaTypes(DefinitionLoader loader) { schemaTypes = SchemaUtils.loadSchemaTypes(loader.getBaseURI(), loader); schemaTypeLoader = XmlBeans.typeLoaderUnion(new SchemaTypeLoader[]{schemaTypes, XmlBeans.getBuiltinTypeSystem()}); } } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/SchemaLoader.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlOptions; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. *

* Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base */ interface SchemaLoader { XmlObject loadXmlObject(String wsdlUrl, XmlOptions options) throws Exception; String getBaseURI(); } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/SchemaUtils.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.apache.xmlbeans.*; import org.reficio.ws.SoapBuilderException; import org.reficio.ws.common.ResourceUtils; import org.w3c.dom.*; import javax.xml.namespace.QName; import java.io.File; import java.net.URL; import java.util.*; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. * * Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base * - changing the mechanism using which external resources are loaded */ /** * XML-Schema related tools * * @author Ole.Matzura */ class SchemaUtils { private final static Logger log = Logger.getLogger(SchemaUtils.class); private static Map defaultSchemas = new HashMap(); public static final boolean STRICT_SCHEMA_TYPES = false; static { initDefaultSchemas(); } public static URL loadResoruce(String resourceName) { return ResourceUtils.getResourceWithAbsolutePackagePath( SchemaUtils.class, "/xsds/", resourceName); } public static void initDefaultSchemas() { try { defaultSchemas.clear(); loadDefaultSchema(loadResoruce("xop.xsd")); loadDefaultSchema(loadResoruce("XMLSchema.xsd")); loadDefaultSchema(loadResoruce("xml.xsd")); loadDefaultSchema(loadResoruce("swaref.xsd")); loadDefaultSchema(loadResoruce("xmime200505.xsd")); loadDefaultSchema(loadResoruce("xmime200411.xsd")); loadDefaultSchema(loadResoruce("soapEnvelope.xsd")); loadDefaultSchema(loadResoruce("soapEncoding.xsd")); loadDefaultSchema(loadResoruce("soapEnvelope12.xsd")); loadDefaultSchema(loadResoruce("soapEncoding12.xsd")); } catch (Exception e) { throw new SoapBuilderException(e); } } private static void loadDefaultSchema(URL url) throws Exception { XmlObject xmlObject = XmlUtils.createXmlObject(url); if (!((Document) xmlObject.getDomNode()).getDocumentElement().getNamespaceURI().equals(Constants.XSD_NS)) return; String targetNamespace = getTargetNamespace(xmlObject); if (defaultSchemas.containsKey(targetNamespace)) log.warn("Overriding schema for targetNamespace " + targetNamespace); defaultSchemas.put(targetNamespace, xmlObject); log.debug("Added default schema from " + url.getPath() + " with targetNamespace " + targetNamespace); } public static SchemaTypeSystem loadSchemaTypes(String wsdlUrl, SchemaLoader loader) { try { log.debug("Loading schema types from [" + wsdlUrl + "]"); ArrayList schemas = new ArrayList(getSchemas(wsdlUrl, loader).values()); return buildSchemaTypes(schemas); } catch (Exception e) { throw new SoapBuilderException(e); } } public static SchemaTypeSystem buildSchemaTypes(List schemas) { XmlOptions options = new XmlOptions(); options.setCompileNoValidation(); options.setCompileNoPvrRule(); options.setCompileDownloadUrls(); options.setCompileNoUpaRule(); options.setValidateTreatLaxAsSkip(); for (int c = 0; c < schemas.size(); c++) { XmlObject xmlObject = schemas.get(c); if (xmlObject == null || !((Document) xmlObject.getDomNode()).getDocumentElement().getNamespaceURI() .equals(Constants.XSD_NS)) { schemas.remove(c); c--; } } // TODO boolean strictSchemaTypes = STRICT_SCHEMA_TYPES;//SoapUI.getSettings().getBoolean( WsdlSettings.STRICT_SCHEMA_TYPES ); if (!strictSchemaTypes) { Set mdefNamespaces = new HashSet(); for (XmlObject xObj : schemas) { mdefNamespaces.add(getTargetNamespace(xObj)); } options.setCompileMdefNamespaces(mdefNamespaces); } ArrayList errorList = new ArrayList(); options.setErrorListener(errorList); XmlCursor cursor = null; try { // remove imports for (int c = 0; c < schemas.size(); c++) { XmlObject s = schemas.get(c); Map map = new HashMap(); cursor = s.newCursor(); cursor.toStartDoc(); if (toNextContainer(cursor)) cursor.getAllNamespaces(map); else log.warn("Can not get namespaces for " + s); String tns = getTargetNamespace(s); // log.info( "schema for [" + tns + "] contained [" + map.toString() // + "] namespaces" ); if (strictSchemaTypes && defaultSchemas.containsKey(tns)) { schemas.remove(c); c--; } else { removeImports(s); } cursor.dispose(); cursor = null; } // schemas.add( soapVersion.getSoapEncodingSchema()); // schemas.add( soapVersion.getSoapEnvelopeSchema()); schemas.addAll(defaultSchemas.values()); SchemaTypeSystem sts = XmlBeans.compileXsd(schemas.toArray(new XmlObject[schemas.size()]), XmlBeans.getBuiltinTypeSystem(), options); return sts; // return XmlBeans.typeLoaderUnion(new SchemaTypeLoader[] { sts, // XmlBeans.getBuiltinTypeSystem() }); } catch (Exception e) { throw new SoapBuilderException(e); } finally { for (int c = 0; c < errorList.size(); c++) { log.warn("Error: " + errorList.get(c)); } if (cursor != null) cursor.dispose(); } } public static boolean toNextContainer(XmlCursor cursor) { while (!cursor.isContainer() && !cursor.isEnddoc()) cursor.toNextToken(); return cursor.isContainer(); } public static String getTargetNamespace(XmlObject s) { return ((Document) s.getDomNode()).getDocumentElement().getAttribute("targetNamespace"); } public static Map getSchemas(String wsdlUrl, SchemaLoader loader) { Map result = new HashMap(); getSchemas(wsdlUrl, result, loader, null /* , false */); return result; } /** * Returns a map mapping urls to corresponding XmlSchema XmlObjects for the * specified wsdlUrl */ public static void getSchemas(String wsdlUrl, Map existing, SchemaLoader loader, String tns) { if (existing.containsKey(wsdlUrl)) { return; } log.debug("Getting schema " + wsdlUrl); ArrayList errorList = new ArrayList(); Map result = new HashMap(); boolean common = false; try { XmlOptions options = new XmlOptions(); options.setCompileNoValidation(); options.setSaveUseOpenFrag(); options.setErrorListener(errorList); options.setSaveSyntheticDocumentElement(new QName(Constants.XSD_NS, "schema")); XmlObject xmlObject = loader.loadXmlObject(wsdlUrl, options); if (xmlObject == null) throw new Exception("Failed to load schema from [" + wsdlUrl + "]"); Document dom = (Document) xmlObject.getDomNode(); Node domNode = dom.getDocumentElement(); // is this an xml schema? if (domNode.getLocalName().equals("schema") && Constants.XSD_NS.equals(domNode.getNamespaceURI())) { // set targetNamespace (this happens if we are following an include // statement) if (tns != null) { Element elm = ((Element) domNode); if (!elm.hasAttribute("targetNamespace")) { common = true; elm.setAttribute("targetNamespace", tns); } // check for namespace prefix for targetNamespace NamedNodeMap attributes = elm.getAttributes(); int c = 0; for (; c < attributes.getLength(); c++) { Node item = attributes.item(c); if (item.getNodeName().equals("xmlns")) break; if (item.getNodeValue().equals(tns) && item.getNodeName().startsWith("xmlns")) break; } if (c == attributes.getLength()) elm.setAttribute("xmlns", tns); } if (common && !existing.containsKey(wsdlUrl + "@" + tns)) result.put(wsdlUrl + "@" + tns, xmlObject); else result.put(wsdlUrl, xmlObject); } else { existing.put(wsdlUrl, null); XmlObject[] schemas = xmlObject.selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:schema"); for (int i = 0; i < schemas.length; i++) { XmlCursor xmlCursor = schemas[i].newCursor(); String xmlText = xmlCursor.getObject().xmlText(options); // schemas[i] = XmlObject.Factory.parse( xmlText, options ); schemas[i] = XmlUtils.createXmlObject(xmlText, options); schemas[i].documentProperties().setSourceName(wsdlUrl); result.put(wsdlUrl + "@" + (i + 1), schemas[i]); } XmlObject[] wsdlImports = xmlObject.selectPath("declare namespace s='" + Constants.WSDL11_NS + "' .//s:import/@location"); for (int i = 0; i < wsdlImports.length; i++) { String location = ((SimpleValue) wsdlImports[i]).getStringValue(); if (location != null) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, null); } } XmlObject[] wadl10Imports = xmlObject.selectPath("declare namespace s='" + Constants.WADL10_NS + "' .//s:grammars/s:include/@href"); for (int i = 0; i < wadl10Imports.length; i++) { String location = ((SimpleValue) wadl10Imports[i]).getStringValue(); if (location != null) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, null); } } XmlObject[] wadlImports = xmlObject.selectPath("declare namespace s='" + Constants.WADL11_NS + "' .//s:grammars/s:include/@href"); for (int i = 0; i < wadlImports.length; i++) { String location = ((SimpleValue) wadlImports[i]).getStringValue(); if (location != null) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, null); } } } existing.putAll(result); XmlObject[] schemas = result.values().toArray(new XmlObject[result.size()]); for (int c = 0; c < schemas.length; c++) { xmlObject = schemas[c]; XmlObject[] schemaImports = xmlObject.selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:import/@schemaLocation"); for (int i = 0; i < schemaImports.length; i++) { String location = ((SimpleValue) schemaImports[i]).getStringValue(); Element elm = ((Attr) schemaImports[i].getDomNode()).getOwnerElement(); if (location != null && !defaultSchemas.containsKey(elm.getAttribute("namespace"))) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, null); } } XmlObject[] schemaIncludes = xmlObject.selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:include/@schemaLocation"); for (int i = 0; i < schemaIncludes.length; i++) { String location = ((SimpleValue) schemaIncludes[i]).getStringValue(); if (location != null) { String targetNS = getTargetNamespace(xmlObject); if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getSchemas(location, existing, loader, targetNS); } } } } catch (Exception e) { throw new SoapBuilderException(e); } } public static void getDefinitionParts(String origWsdlUrl, Map existing, SchemaLoader loader) throws Exception { String wsdlUrl = origWsdlUrl; if (existing.containsKey(wsdlUrl)) return; XmlObject xmlObject = loader.loadXmlObject(wsdlUrl, null); existing.put(wsdlUrl, xmlObject); // wsdlUrl = loader.getBaseURI(); selectDefinitionParts(wsdlUrl, existing, loader, xmlObject, "declare namespace s='" + Constants.WSDL11_NS + "' .//s:import/@location"); selectDefinitionParts(wsdlUrl, existing, loader, xmlObject, "declare namespace s='" + Constants.WADL10_NS + "' .//s:grammars/s:include/@href"); selectDefinitionParts(wsdlUrl, existing, loader, xmlObject, "declare namespace s='" + Constants.WADL11_NS + "' .//s:grammars/s:include/@href"); selectDefinitionParts(wsdlUrl, existing, loader, xmlObject, "declare namespace s='" + Constants.XSD_NS + "' .//s:import/@schemaLocation"); selectDefinitionParts(wsdlUrl, existing, loader, xmlObject, "declare namespace s='" + Constants.XSD_NS + "' .//s:include/@schemaLocation"); } public static String joinRelativeUrl(String baseUrl, String url) { if (baseUrl.indexOf('?') > 0) baseUrl = baseUrl.substring(0, baseUrl.indexOf('?')); boolean isWindowsUrl = baseUrl.indexOf('\\') >= 0; boolean isUsedInUnix = File.separatorChar == '/'; if (isUsedInUnix && isWindowsUrl) { baseUrl = baseUrl.replace('\\', '/'); url = url.replace('\\', '/'); } boolean isFile = baseUrl.startsWith("file:"); int ix = baseUrl.lastIndexOf('\\'); if (ix == -1) ix = baseUrl.lastIndexOf('/'); // absolute? if (url.startsWith("/") && !isFile) { ix = baseUrl.indexOf("/", baseUrl.indexOf("//") + 2); return baseUrl.substring(0, ix) + url; } // remove leading "./" while (url.startsWith(".\\") || url.startsWith("./")) url = url.substring(2); // remove leading "../" while (url.startsWith("../") || url.startsWith("..\\")) { int ix2 = baseUrl.lastIndexOf('\\', ix - 1); if (ix2 == -1) ix2 = baseUrl.lastIndexOf('/', ix - 1); if (ix2 == -1) break; baseUrl = baseUrl.substring(0, ix2 + 1); ix = ix2; url = url.substring(3); } // remove "/./" while (url.indexOf("/./") != -1 || url.indexOf("\\.\\") != -1) { int ix2 = url.indexOf("/./"); if (ix2 == -1) ix2 = url.indexOf("\\.\\"); url = url.substring(0, ix2) + url.substring(ix2 + 2); } // remove "/../" while (url.indexOf("/../") != -1 || url.indexOf("\\..\\") != -1) { int ix2 = -1; int ix3 = url.indexOf("/../"); if (ix3 == -1) { ix3 = url.indexOf("\\..\\"); ix2 = url.lastIndexOf('\\', ix3 - 1); } else { ix2 = url.lastIndexOf('/', ix3 - 1); } if (ix2 == -1) break; url = url.substring(0, ix2) + url.substring(ix3 + 3); } String result = baseUrl.substring(0, ix + 1) + url; if (isFile) result = result.replace('/', File.separatorChar); return result; } private static void selectDefinitionParts(String wsdlUrl, Map existing, SchemaLoader loader, XmlObject xmlObject, String path) throws Exception { XmlObject[] wsdlImports = xmlObject.selectPath(path); for (int i = 0; i < wsdlImports.length; i++) { String location = ((SimpleValue) wsdlImports[i]).getStringValue(); if (location != null) { if (StringUtils.isNotBlank(location)) { if (!location.startsWith("file:") && location.indexOf("://") == -1) location = joinRelativeUrl(wsdlUrl, location); getDefinitionParts(location, existing, loader); } else { Node domNode = ((Attr) wsdlImports[i].getDomNode()).getOwnerElement(); domNode.getParentNode().removeChild(domNode); } } } } /** * Extracts namespaces - used in tool integrations for mapping.. */ public static Collection extractNamespaces(SchemaTypeSystem schemaTypes, boolean removeDefault) { Set namespaces = new HashSet(); SchemaType[] globalTypes = schemaTypes.globalTypes(); for (int c = 0; c < globalTypes.length; c++) { namespaces.add(globalTypes[c].getName().getNamespaceURI()); } if (removeDefault) { namespaces.removeAll(defaultSchemas.keySet()); namespaces.remove(Constants.SOAP11_ENVELOPE_NS); namespaces.remove(Constants.SOAP_ENCODING_NS); } return namespaces; } /** * Used when creating a TypeSystem from a complete collection of * SchemaDocuments so that referenced types are not downloaded (again) */ public static void removeImports(XmlObject xmlObject) throws XmlException { XmlObject[] imports = xmlObject.selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:import"); for (int c = 0; c < imports.length; c++) { XmlCursor cursor = imports[c].newCursor(); cursor.removeXml(); cursor.dispose(); } XmlObject[] includes = xmlObject.selectPath("declare namespace s='" + Constants.XSD_NS + "' .//s:include"); for (int c = 0; c < includes.length; c++) { XmlCursor cursor = includes[c].newCursor(); cursor.removeXml(); cursor.dispose(); } } } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/SoapLegacyFacade.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.reficio.ws.SoapBuilderException; import org.reficio.ws.SoapContext; import org.reficio.ws.SoapValidationException; import javax.wsdl.*; import javax.wsdl.extensions.soap.SOAPBinding; import javax.wsdl.extensions.soap12.SOAP12Binding; import javax.xml.namespace.QName; import java.io.File; import java.net.URL; import java.util.Collection; import java.util.List; /** * @author Tom Bujok * @since 1.0.0 */ public class SoapLegacyFacade { public static enum Soap {SOAP_1_1, SOAP_1_2} private static final String RPC = "rpc"; private SoapMessageBuilder messageBuilder; public SoapLegacyFacade(URL wsdlUrl) throws WSDLException { this.messageBuilder = new SoapMessageBuilder(wsdlUrl); } public String buildSoapMessageFromInput(Binding binding, BindingOperation bindingOperation, SoapContext context) { try { return messageBuilder.buildSoapMessageFromInput(binding, bindingOperation, context); } catch (Exception e) { throw new SoapBuilderException(e); } } public String buildSoapMessageFromOutput(Binding binding, BindingOperation bindingOperation, SoapContext context) { try { return messageBuilder.buildSoapMessageFromOutput(binding, bindingOperation, context); } catch (Exception e) { throw new SoapBuilderException(e); } } public void validateSoapRequestMessage(Binding binding, BindingOperation operation, String message, boolean strict) { WsdlValidator validator = new WsdlValidator(messageBuilder, binding); List result = validator.assertRequest(operation, message, strict); if (!result.isEmpty()) { throw new SoapValidationException(result); } } public void validateSoapResponseMessage(Binding binding, BindingOperation operation, String message, boolean strict) { WsdlValidator validator = new WsdlValidator(messageBuilder, binding); List result = validator.assertResponse(operation, message, strict); if (!result.isEmpty()) { throw new SoapValidationException(result); } } public String buildFault(String code, String message, Binding binding, SoapContext context) { return messageBuilder.buildFault(code, message, binding, context); } public String buildEmptyFault(Binding binding, SoapContext context) { return messageBuilder.buildEmptyFault(binding, context); } public String buildEmptyMessage(Binding binding, SoapContext context) { return messageBuilder.buildEmptyMessage(binding, context); } public URL saveWsdl(String rootFileName, File folder) { return messageBuilder.saveWsdl(rootFileName, folder); } public static URL saveWsdl(URL wsdlUrl, String rootFileName, File folder) { try { return SoapMessageBuilder.saveWsdl(rootFileName, wsdlUrl, folder); } catch (WSDLException e) { throw new SoapBuilderException(e); } } public Binding getBindingByName(QName bindingName) { return messageBuilder.getBindingByName(bindingName); } public List getBindingNames() { return messageBuilder.getBindingNames(); } public static String buildEmptyMessage(SoapVersion soapVersion, SoapContext context) { return SoapMessageBuilder.buildEmptyMessage(soapVersion, context); } public static String buildEmptyFault(SoapVersion soapVersion, SoapContext context) { return SoapMessageBuilder.buildEmptyFault(soapVersion, context); } public static String buildFault(String code, String message, SoapVersion soapVersion, SoapContext context) { return SoapMessageBuilder.buildFault(code, message, soapVersion, context); } private static SoapVersion transformSoapVersion(Soap soapVersion) { if (soapVersion.equals(Soap.SOAP_1_1)) { return SoapVersion.Soap11; } else { return SoapVersion.Soap12; } } public static String buildEmptyMessage(Soap version, SoapContext context) { return SoapLegacyFacade.buildEmptyMessage(transformSoapVersion(version), context); } public static String buildEmptyFault(Soap version, SoapContext context) { return SoapLegacyFacade.buildEmptyFault(transformSoapVersion(version), context); } public static String buildFault(Soap version, String code, String message, SoapContext context) { return SoapLegacyFacade.buildFault(code, message, transformSoapVersion(version), context); } public static boolean isRpc(Binding binding) { SOAPBinding soapBinding = WsdlUtils .getExtensiblityElement(binding.getExtensibilityElements(), SOAPBinding.class); if (soapBinding != null) return RPC.equalsIgnoreCase(soapBinding.getStyle()); SOAP12Binding soap12Binding = WsdlUtils.getExtensiblityElement(binding.getExtensibilityElements(), SOAP12Binding.class); if (soap12Binding != null) return RPC.equalsIgnoreCase(soap12Binding.getStyle()); return false; } public static String getSoapEndpoint(Port port) { return WsdlUtils.getSoapEndpoint(port); } @SuppressWarnings("unchecked") public Collection getServices() { return (Collection) messageBuilder.getDefinition().getServices().values(); } public boolean isOutputSoapEncoded(BindingOperation operation) { return WsdlUtils.isOutputSoapEncoded(operation); } public boolean isInputSoapEncoded(BindingOperation operation) { return WsdlUtils.isInputSoapEncoded(operation); } } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/SoapMessageBuilder.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import com.ibm.wsdl.xml.WSDLReaderImpl; import org.apache.log4j.Logger; import org.apache.xmlbeans.SchemaGlobalElement; import org.apache.xmlbeans.SchemaType; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlObject; import org.reficio.ws.SoapBuilderException; import org.reficio.ws.SoapContext; import org.reficio.ws.annotation.ThreadSafe; import org.reficio.ws.common.Wsdl11Writer; import org.w3c.dom.Document; import org.w3c.dom.Node; import javax.wsdl.*; import javax.wsdl.extensions.soap.SOAPBinding; import javax.wsdl.extensions.soap12.SOAP12Binding; import javax.wsdl.xml.WSDLReader; import javax.xml.namespace.QName; import java.io.File; import java.io.StringWriter; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. * * Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base * - rename to SoapBuilder (from SoapMessageBuilder) * - slight reorganization of the public API and arguments of the methods * - introduction of OperationWrapper and SoapContext classes * - addition of saveWSDL and createAndSave methods */ /** * Builds SOAP requests according to WSDL/XSD definitions * * @author Ole.Matzura */ @ThreadSafe @SuppressWarnings("unchecked") class SoapMessageBuilder { private final static Logger log = Logger.getLogger(SoapMessageBuilder.class); // should be thread safe it not modified after it has been initialized private Definition definition; // should be thread safe it not modified after it has been initialized private SchemaDefinitionWrapper definitionWrapper; // ---------------------------------------------------------- // Constructors and factory methods // ---------------------------------------------------------- /** * @param wsdlUrl url of the wsdl to import * @throws WSDLException thrown in case of import errors */ public SoapMessageBuilder(URL wsdlUrl) throws WSDLException { WSDLReader reader = new WSDLReaderImpl(); reader.setFeature("javax.wsdl.verbose", false); this.definition = reader.readWSDL(wsdlUrl.toString()); this.definitionWrapper = new SchemaDefinitionWrapper(definition, wsdlUrl.toString()); } /** * Constructs a new SoapBuilder instance importing the wsdl from the specified wsdlUrl. * If the import is successful it saves the wsdl/xsd files to the target folder giving * the top-level wsdl the specified baseName and setting the documentBaseUri to the newly * saved wsdl uri. If the import is not successful an exception will be thrown and files * will not be saved. Method expects that the targetFolder already exists. * * @param wsdlUrl url of the wsdl to import * @param targetFolder folder in which all the files are be stored - folder has to exist, no subfolders are created, * @param fileBaseName name of the top level file, without extension -> wsdl will be added by default * @return instance of the soap-builder which documentBaseUri is set to the url of the locally saved wsdl * @throws WSDLException thrown in case of import errors */ public static SoapMessageBuilder createAndSave(URL wsdlUrl, File targetFolder, String fileBaseName) throws WSDLException { SoapMessageBuilder soapBuilder = new SoapMessageBuilder(wsdlUrl); URL url = soapBuilder.saveWsdl(fileBaseName, targetFolder); soapBuilder.getDefinition().setDocumentBaseURI(url.toString()); return soapBuilder; } // ---------------------------------------------------------- // WSDLs and XSDs MARSHALLER // ---------------------------------------------------------- private static void saveDefinition(String fileBaseName, Definition definition, File targetFolder) { if (targetFolder.exists() == false || targetFolder.isDirectory() == false) { throw new IllegalArgumentException("Target folder does not exist or is not a folder [" + targetFolder.getPath() + "]"); } Wsdl11Writer writer = new Wsdl11Writer(targetFolder); writer.writeWSDL(fileBaseName, definition); } private static URL getSavedWsdlUrl(String fileBaseName, File targetFolder) { File file = new File(targetFolder, fileBaseName + ".wsdl"); try { return file.toURI().toURL(); } catch (MalformedURLException e) { throw new SoapBuilderException("Error saving url", e); } } /** * Saves wsdl recursively fetching all referenced wsdls and schemas fixing their location tags * * @param fileBaseName name of the top level file, without extension -> wsdl will be added by default * @param targetFolder folder in which all the files are stored - folder has to exist, no subfolders are created, */ public URL saveWsdl(String fileBaseName, File targetFolder) { saveDefinition(fileBaseName, definition, targetFolder); return getSavedWsdlUrl(fileBaseName, targetFolder); } /** * Saves wsdl recursively fetching all referenced wsdls and schemas fixing their location tags * * @param fileBaseName name of the top level file, without extension -> wsdl will be added by default * @param wsdlUrl url of the wsdl to save * @param targetFolder folder in which all the files are be stored - folder has to exist, no subfolders are created, * @throws WSDLException thrown in case of import errors */ public static URL saveWsdl(String fileBaseName, URL wsdlUrl, File targetFolder) throws WSDLException { WSDLReader reader = new WSDLReaderImpl(); reader.setFeature("javax.wsdl.verbose", false); Definition definition = reader.readWSDL(wsdlUrl.toString()); saveDefinition(fileBaseName, definition, targetFolder); return getSavedWsdlUrl(fileBaseName, targetFolder); } // ---------------------------------------------------------- // EMPTY MESSAGE GENERATORS // ---------------------------------------------------------- public String buildEmptyMessage(QName bindingQName, SoapContext context) { return buildEmptyMessage(getSoapVersion(getBindingByName(bindingQName)), context); } public String buildEmptyMessage(Binding binding, SoapContext context) { return buildEmptyMessage(getSoapVersion(binding), context); } public static String buildEmptyMessage(SoapVersion soapVersion, SoapContext context) { SampleXmlUtil generator = new SampleXmlUtil(false, context); return generator.createSample(soapVersion.getEnvelopeType()); } // ---------------------------------------------------------- // FAULT MESSAGE GENERATORS // ---------------------------------------------------------- public static String buildFault(String faultcode, String faultstring, SoapVersion soapVersion, SoapContext context) { SampleXmlUtil generator = new SampleXmlUtil(false, context); generator.setTypeComment(false); generator.setIgnoreOptional(true); String emptyResponse = buildEmptyFault(generator, soapVersion, context); if (soapVersion == SoapVersion.Soap11) { emptyResponse = XmlUtils.setXPathContent(emptyResponse, "//faultcode", faultcode); emptyResponse = XmlUtils.setXPathContent(emptyResponse, "//faultstring", faultstring); } else if (soapVersion == SoapVersion.Soap12) { emptyResponse = XmlUtils.setXPathContent(emptyResponse, "//soap:Value", faultcode); emptyResponse = XmlUtils.setXPathContent(emptyResponse, "//soap:Text", faultstring); emptyResponse = XmlUtils.setXPathContent(emptyResponse, "//soap:Text/@xml:lang", "en"); } return emptyResponse; } public String buildFault(String faultcode, String faultstring, QName bindingQName, SoapContext context) { return buildFault(faultcode, faultstring, getSoapVersion(getBindingByName(bindingQName)), context); } public String buildFault(String faultcode, String faultstring, Binding binding, SoapContext context) { return buildFault(faultcode, faultstring, getSoapVersion(binding), context); } public String buildEmptyFault(QName bindingQName, SoapContext context) { return buildEmptyFault(getSoapVersion(getBindingByName(bindingQName)), context); } public String buildEmptyFault(Binding binding, SoapContext context) { return buildEmptyFault(getSoapVersion(binding), context); } public static String buildEmptyFault(SoapVersion soapVersion, SoapContext context) { SampleXmlUtil generator = new SampleXmlUtil(false, context); String emptyResponse = buildEmptyFault(generator, soapVersion, context); return emptyResponse; } // ---------------------------------------------------------- // INPUT MESSAGE GENERATORS // ---------------------------------------------------------- public String buildSoapMessageFromInput(Binding binding, BindingOperation bindingOperation, SoapContext context) throws Exception { SoapVersion soapVersion = getSoapVersion(binding); boolean inputSoapEncoded = WsdlUtils.isInputSoapEncoded(bindingOperation); SampleXmlUtil xmlGenerator = new SampleXmlUtil(inputSoapEncoded, context); XmlObject object = XmlObject.Factory.newInstance(); XmlCursor cursor = object.newCursor(); cursor.toNextToken(); cursor.beginElement(soapVersion.getEnvelopeQName()); if (inputSoapEncoded) { cursor.insertNamespace("xsi", Constants.XSI_NS); cursor.insertNamespace("xsd", Constants.XSD_NS); } cursor.toFirstChild(); cursor.beginElement(soapVersion.getBodyQName()); cursor.toFirstChild(); if (WsdlUtils.isRpc(definition, bindingOperation)) { buildRpcRequest(bindingOperation, soapVersion, cursor, xmlGenerator); } else { buildDocumentRequest(bindingOperation, cursor, xmlGenerator); } if (context.isAlwaysBuildHeaders()) { BindingInput bindingInput = bindingOperation.getBindingInput(); if (bindingInput != null) { List extensibilityElements = bindingInput.getExtensibilityElements(); List soapHeaders = WsdlUtils.getSoapHeaders(extensibilityElements); addHeaders(soapHeaders, soapVersion, cursor, xmlGenerator); } } cursor.dispose(); try { StringWriter writer = new StringWriter(); XmlUtils.serializePretty(object, writer); return writer.toString(); } catch (Exception e) { e.printStackTrace(); return object.xmlText(); } } // ---------------------------------------------------------- // OUTPUT MESSAGE GENERATORS // ---------------------------------------------------------- public String buildSoapMessageFromOutput(Binding binding, BindingOperation bindingOperation, SoapContext context) throws Exception { boolean inputSoapEncoded = WsdlUtils.isInputSoapEncoded(bindingOperation); SampleXmlUtil xmlGenerator = new SampleXmlUtil(inputSoapEncoded, context); SoapVersion soapVersion = getSoapVersion(binding); XmlObject object = XmlObject.Factory.newInstance(); XmlCursor cursor = object.newCursor(); cursor.toNextToken(); cursor.beginElement(soapVersion.getEnvelopeQName()); if (inputSoapEncoded) { cursor.insertNamespace("xsi", Constants.XSI_NS); cursor.insertNamespace("xsd", Constants.XSD_NS); } cursor.toFirstChild(); cursor.beginElement(soapVersion.getBodyQName()); cursor.toFirstChild(); if (WsdlUtils.isRpc(definition, bindingOperation)) { buildRpcResponse(bindingOperation, soapVersion, cursor, xmlGenerator); } else { buildDocumentResponse(bindingOperation, cursor, xmlGenerator); } if (context.isAlwaysBuildHeaders()) { // bindingOutput will be null for one way operations, // but then we shouldn't be here in the first place??? BindingOutput bindingOutput = bindingOperation.getBindingOutput(); if (bindingOutput != null) { List extensibilityElements = bindingOutput.getExtensibilityElements(); List soapHeaders = WsdlUtils.getSoapHeaders(extensibilityElements); addHeaders(soapHeaders, soapVersion, cursor, xmlGenerator); } } cursor.dispose(); try { StringWriter writer = new StringWriter(); XmlUtils.serializePretty(object, writer); return writer.toString(); } catch (Exception e) { log.warn("Exception during message generation", e); return object.xmlText(); } } // ---------------------------------------------------------- // UTILS // ---------------------------------------------------------- public Definition getDefinition() { return definition; } public SchemaDefinitionWrapper getSchemaDefinitionWrapper() { return definitionWrapper; } public BindingOperation getOperationByName(QName bindingName, String operationName, String operationInputName, String operationOutputName) { Binding binding = getBindingByName(bindingName); if (binding == null) { return null; } BindingOperation operation = binding.getBindingOperation(operationName, operationInputName, operationOutputName); if (operation == null) { throw new SoapBuilderException("Operation not found"); } return operation; } public Binding getBindingByName(QName bindingName) { Binding binding = this.definition.getBinding(bindingName); if (binding == null) { throw new SoapBuilderException("Binding not found"); } return binding; } public List getBindingNames() { return new ArrayList(definition.getAllBindings().keySet()); } public static SoapVersion getSoapVersion(Binding binding) { List list = binding.getExtensibilityElements(); SOAPBinding soapBinding = WsdlUtils.getExtensiblityElement(list, SOAPBinding.class); if (soapBinding != null) { if ((soapBinding.getTransportURI().startsWith(Constants.SOAP_HTTP_TRANSPORT) || soapBinding .getTransportURI().startsWith(Constants.SOAP_MICROSOFT_TCP))) { return SoapVersion.Soap11; } } SOAP12Binding soap12Binding = WsdlUtils.getExtensiblityElement(list, SOAP12Binding.class); if (soap12Binding != null) { if (soap12Binding.getTransportURI().startsWith(Constants.SOAP_HTTP_TRANSPORT) || soap12Binding.getTransportURI().startsWith(Constants.SOAP12_HTTP_BINDING_NS) || soap12Binding.getTransportURI().startsWith(Constants.SOAP_MICROSOFT_TCP)) { return SoapVersion.Soap12; } } throw new SoapBuilderException("SOAP binding not recognized"); } // -------------------------------------------------------------------------- // Internal methods - END OF PUBLIC API // -------------------------------------------------------------------------- private void addHeaders(List headers, SoapVersion soapVersion, XmlCursor cursor, SampleXmlUtil xmlGenerator) throws Exception { // reposition cursor.toStartDoc(); cursor.toChild(soapVersion.getEnvelopeQName()); cursor.toFirstChild(); cursor.beginElement(soapVersion.getHeaderQName()); cursor.toFirstChild(); for (int i = 0; i < headers.size(); i++) { WsdlUtils.SoapHeader header = headers.get(i); Message message = definition.getMessage(header.getMessage()); if (message == null) { log.error("Missing message for header: " + header.getMessage()); continue; } Part part = message.getPart(header.getPart()); if (part != null) createElementForPart(part, cursor, xmlGenerator); else log.error("Missing part for header; " + header.getPart()); } } private void buildDocumentResponse(BindingOperation bindingOperation, XmlCursor cursor, SampleXmlUtil xmlGenerator) throws Exception { Part[] parts = WsdlUtils.getOutputParts(bindingOperation); for (int i = 0; i < parts.length; i++) { Part part = parts[i]; if (!WsdlUtils.isAttachmentOutputPart(part, bindingOperation) && (part.getElementName() != null || part.getTypeName() != null)) { XmlCursor c = cursor.newCursor(); c.toLastChild(); createElementForPart(part, c, xmlGenerator); c.dispose(); } } } private void buildDocumentRequest(BindingOperation bindingOperation, XmlCursor cursor, SampleXmlUtil xmlGenerator) throws Exception { Part[] parts = WsdlUtils.getInputParts(bindingOperation); for (int i = 0; i < parts.length; i++) { Part part = parts[i]; if (!WsdlUtils.isAttachmentInputPart(part, bindingOperation) && (part.getElementName() != null || part.getTypeName() != null)) { XmlCursor c = cursor.newCursor(); c.toLastChild(); createElementForPart(part, c, xmlGenerator); c.dispose(); } } } private void createElementForPart(Part part, XmlCursor cursor, SampleXmlUtil xmlGenerator) throws Exception { QName elementName = part.getElementName(); QName typeName = part.getTypeName(); if (elementName != null) { cursor.beginElement(elementName); if (definitionWrapper.hasSchemaTypes()) { SchemaGlobalElement elm = definitionWrapper.getSchemaTypeLoader().findElement(elementName); if (elm != null) { cursor.toFirstChild(); xmlGenerator.createSampleForType(elm.getType(), cursor); } else log.error("Could not find element [" + elementName + "] specified in part [" + part.getName() + "]"); } cursor.toParent(); } else { // cursor.beginElement( new QName( // wsdlContext.getWsdlDefinition().getTargetNamespace(), part.getName() // )); cursor.beginElement(part.getName()); if (typeName != null && definitionWrapper.hasSchemaTypes()) { SchemaType type = definitionWrapper.getSchemaTypeLoader().findType(typeName); if (type != null) { cursor.toFirstChild(); xmlGenerator.createSampleForType(type, cursor); } else log.error("Could not find type [" + typeName + "] specified in part [" + part.getName() + "]"); } cursor.toParent(); } } private void buildRpcRequest(BindingOperation bindingOperation, SoapVersion soapVersion, XmlCursor cursor, SampleXmlUtil xmlGenerator) throws Exception { // rpc requests use the operation name as root element String ns = WsdlUtils.getSoapBodyNamespace(bindingOperation.getBindingInput().getExtensibilityElements()); if (ns == null) { ns = WsdlUtils.getTargetNamespace(definition); log.warn("missing namespace on soapbind:body for RPC request, using targetNamespace instead (BP violation)"); } cursor.beginElement(new QName(ns, bindingOperation.getName())); // TODO if (xmlGenerator.isSoapEnc()) cursor.insertAttributeWithValue(new QName(soapVersion.getEnvelopeNamespace(), "encodingStyle"), soapVersion.getEncodingNamespace()); Part[] inputParts = WsdlUtils.getInputParts(bindingOperation); for (int i = 0; i < inputParts.length; i++) { Part part = inputParts[i]; if (WsdlUtils.isAttachmentInputPart(part, bindingOperation)) { // TODO - generation of attachment flag could be externalized // if (iface.getSettings().getBoolean(WsdlSettings.ATTACHMENT_PARTS)) { XmlCursor c = cursor.newCursor(); c.toLastChild(); c.beginElement(part.getName()); c.insertAttributeWithValue("href", part.getName() + "Attachment"); c.dispose(); // } } else { if (definitionWrapper.hasSchemaTypes()) { QName typeName = part.getTypeName(); if (typeName != null) { // TODO - Don't know whether will work // SchemaType type = wsdlContext.getInterfaceDefinition().findType(typeName); SchemaType type = definitionWrapper.findType(typeName); if (type != null) { XmlCursor c = cursor.newCursor(); c.toLastChild(); c.insertElement(part.getName()); c.toPrevToken(); xmlGenerator.createSampleForType(type, c); c.dispose(); } else log.warn("Failed to find type [" + typeName + "]"); } else { SchemaGlobalElement element = definitionWrapper.getSchemaTypeLoader().findElement(part.getElementName()); if (element != null) { XmlCursor c = cursor.newCursor(); c.toLastChild(); c.insertElement(element.getName()); c.toPrevToken(); xmlGenerator.createSampleForType(element.getType(), c); c.dispose(); } else log.warn("Failed to find element [" + part.getElementName() + "]"); } } } } } private void buildRpcResponse(BindingOperation bindingOperation, SoapVersion soapVersion, XmlCursor cursor, SampleXmlUtil xmlGenerator) throws Exception { // rpc requests use the operation name as root element BindingOutput bindingOutput = bindingOperation.getBindingOutput(); String ns = bindingOutput == null ? null : WsdlUtils.getSoapBodyNamespace(bindingOutput .getExtensibilityElements()); if (ns == null) { ns = WsdlUtils.getTargetNamespace(definition); log.warn("missing namespace on soapbind:body for RPC response, using targetNamespace instead (BP violation)"); } cursor.beginElement(new QName(ns, bindingOperation.getName() + "Response")); if (xmlGenerator.isSoapEnc()) cursor.insertAttributeWithValue(new QName(soapVersion.getEnvelopeNamespace(), "encodingStyle"), soapVersion.getEncodingNamespace()); Part[] inputParts = WsdlUtils.getOutputParts(bindingOperation); for (int i = 0; i < inputParts.length; i++) { Part part = inputParts[i]; if (WsdlUtils.isAttachmentOutputPart(part, bindingOperation)) { // if( iface.getSettings().getBoolean( WsdlSettings.ATTACHMENT_PARTS ) ) { XmlCursor c = cursor.newCursor(); c.toLastChild(); c.beginElement(part.getName()); c.insertAttributeWithValue("href", part.getName() + "Attachment"); c.dispose(); } } else { if (definitionWrapper.hasSchemaTypes()) { QName typeName = part.getTypeName(); if (typeName != null) { SchemaType type = definitionWrapper.findType(typeName); if (type != null) { XmlCursor c = cursor.newCursor(); c.toLastChild(); c.insertElement(part.getName()); c.toPrevToken(); xmlGenerator.createSampleForType(type, c); c.dispose(); } else log.warn("Failed to find type [" + typeName + "]"); } else { SchemaGlobalElement element = definitionWrapper.getSchemaTypeLoader().findElement(part.getElementName()); if (element != null) { XmlCursor c = cursor.newCursor(); c.toLastChild(); c.insertElement(element.getName()); c.toPrevToken(); xmlGenerator.createSampleForType(element.getType(), c); c.dispose(); } else log.warn("Failed to find element [" + part.getElementName() + "]"); } } } } } private static String buildEmptyFault(SampleXmlUtil generator, SoapVersion soapVersion, SoapContext context) { String emptyResponse = buildEmptyMessage(soapVersion, context); try { XmlObject xmlObject = XmlUtils.createXmlObject(emptyResponse); XmlCursor cursor = xmlObject.newCursor(); if (cursor.toChild(soapVersion.getEnvelopeQName()) && cursor.toChild(soapVersion.getBodyQName())) { SchemaType faultType = soapVersion.getFaultType(); Node bodyNode = cursor.getDomNode(); Document dom = XmlUtils.parseXml(generator.createSample(faultType)); bodyNode.appendChild(bodyNode.getOwnerDocument().importNode(dom.getDocumentElement(), true)); } cursor.dispose(); emptyResponse = xmlObject.toString(); } catch (Exception e) { throw new SoapBuilderException(e); } return emptyResponse; } } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/SoapVersion.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.commons.lang3.StringUtils; import org.apache.xmlbeans.*; import javax.xml.namespace.QName; import java.io.IOException; import java.util.List; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. * * Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base */ /** * Public behaviour for a SOAP Version * * @author ole.matzura */ interface SoapVersion { public static final SoapVersion11 Soap11 = SoapVersion11.instance; public static final SoapVersion12 Soap12 = SoapVersion12.instance; public QName getEnvelopeQName(); public QName getBodyQName(); public QName getHeaderQName(); public void validateSoapEnvelope(String soapMessage, List errors); public String getContentTypeHttpHeader(String encoding, String soapAction); public String getEnvelopeNamespace(); public String getFaultDetailNamespace(); public String getEncodingNamespace(); public XmlObject getSoapEncodingSchema() throws XmlException, IOException; public XmlObject getSoapEnvelopeSchema() throws XmlException, IOException; /** * Checks if the specified validation error should be ignored for a message * with this SOAP version. (The SOAP-spec may allow some constructions not * allowed by the corresponding XML-Schema) */ public boolean shouldIgnore(XmlValidationError xmlError); public String getContentType(); public SchemaType getEnvelopeType(); public SchemaType getFaultType(); public String getName(); /** * Utilities * * @author ole.matzura */ public static class Utils { public static SoapVersion getSoapVersionForContentType(String contentType, SoapVersion def) { if (StringUtils.isBlank(contentType)) return def; SoapVersion soapVersion = contentType.startsWith(SoapVersion.Soap11.getContentType()) ? SoapVersion.Soap11 : null; soapVersion = soapVersion == null && contentType.startsWith(SoapVersion.Soap12.getContentType()) ? SoapVersion.Soap12 : soapVersion; return soapVersion == null ? def : soapVersion; } } public String getSoapActionHeader(String soapAction); } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/SoapVersion11.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.xmlbeans.*; import org.reficio.ws.SoapBuilderException; import org.reficio.ws.common.ResourceUtils; import org.xmlsoap.schemas.soap.envelope.EnvelopeDocument; import javax.xml.namespace.QName; import java.io.IOException; import java.net.URL; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. * * Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base * - changing the mechanism using which external resources are loaded */ /** * SoapVersion for SOAP 1.1 * * @author ole.matzura */ class SoapVersion11 extends AbstractSoapVersion { private final static QName envelopeQName = new QName(Constants.SOAP11_ENVELOPE_NS, "Envelope"); private final static QName bodyQName = new QName(Constants.SOAP11_ENVELOPE_NS, "Body"); private final static QName faultQName = new QName(Constants.SOAP11_ENVELOPE_NS, "Fault"); private final static QName headerQName = new QName(Constants.SOAP11_ENVELOPE_NS, "Header"); SchemaTypeLoader soapSchema; SchemaType soapEnvelopeType; private XmlObject soapSchemaXml; private XmlObject soapEncodingXml; private SchemaType soapFaultType; public final static SoapVersion11 instance = new SoapVersion11(); private SoapVersion11() { try { XmlOptions options = new XmlOptions(); options.setCompileNoValidation(); options.setCompileNoPvrRule(); options.setCompileDownloadUrls(); options.setCompileNoUpaRule(); options.setValidateTreatLaxAsSkip(); URL soapSchemaXmlResource = ResourceUtils.getResourceWithAbsolutePackagePath(getClass(), "/xsds/", "soapEnvelope.xsd"); soapSchemaXml = XmlUtils.createXmlObject(soapSchemaXmlResource, options); soapSchema = XmlBeans.loadXsd(new XmlObject[]{soapSchemaXml}); soapEnvelopeType = soapSchema.findDocumentType(envelopeQName); soapFaultType = soapSchema.findDocumentType(faultQName); URL soapEncodingXmlResource = ResourceUtils.getResourceWithAbsolutePackagePath(getClass(), "/xsds/", "soapEncoding.xsd"); soapEncodingXml = XmlUtils.createXmlObject(soapEncodingXmlResource, options); } catch (XmlException ex) { throw new SoapBuilderException(ex); } } public SchemaType getEnvelopeType() { return EnvelopeDocument.type; } public String getEnvelopeNamespace() { return Constants.SOAP11_ENVELOPE_NS; } public String getEncodingNamespace() { return Constants.SOAP_ENCODING_NS; } public XmlObject getSoapEncodingSchema() throws XmlException, IOException { return soapEncodingXml; } public XmlObject getSoapEnvelopeSchema() throws XmlException, IOException { return soapSchemaXml; } public String toString() { return "SOAP 1.1"; } public String getContentTypeHttpHeader(String encoding, String soapAction) { if (encoding == null || encoding.trim().length() == 0) return getContentType(); else return getContentType() + ";charset=" + encoding; } public String getSoapActionHeader(String soapAction) { if (soapAction == null || soapAction.length() == 0) { soapAction = "\"\""; } else { soapAction = "\"" + soapAction + "\""; } return soapAction; } public String getContentType() { return "text/xml"; } public QName getBodyQName() { return bodyQName; } public QName getEnvelopeQName() { return envelopeQName; } public QName getHeaderQName() { return headerQName; } protected SchemaTypeLoader getSoapEnvelopeSchemaLoader() { return soapSchema; } public SchemaType getFaultType() { return soapFaultType; } public String getName() { return "SOAP 1.1"; } public String getFaultDetailNamespace() { return ""; } } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/SoapVersion12.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.commons.lang3.StringUtils; import org.apache.xmlbeans.*; import org.reficio.ws.SoapBuilderException; import org.reficio.ws.common.ResourceUtils; import org.w3.x2003.x05.soapEnvelope.EnvelopeDocument; import org.w3.x2003.x05.soapEnvelope.FaultDocument; import javax.xml.namespace.QName; import java.io.IOException; import java.net.URL; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. * * Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base * - changing the mechanism using which external resources are loaded */ /** * SoapVersion for SOAP 1.2 * * @author ole.matzura */ class SoapVersion12 extends AbstractSoapVersion { private final static QName envelopeQName = new QName(Constants.SOAP12_ENVELOPE_NS, "Envelope"); private final static QName bodyQName = new QName(Constants.SOAP12_ENVELOPE_NS, "Body"); private final static QName faultQName = new QName(Constants.SOAP11_ENVELOPE_NS, "Fault"); private final static QName headerQName = new QName(Constants.SOAP12_ENVELOPE_NS, "Header"); public final static SoapVersion12 instance = new SoapVersion12(); private SchemaTypeLoader soapSchema; private XmlObject soapSchemaXml; private XmlObject soapEncodingXml; private SoapVersion12() { try { URL soapSchemaXmlResource = ResourceUtils.getResourceWithAbsolutePackagePath(getClass(), "/xsds/", "soapEnvelope12.xsd"); soapSchemaXml = XmlUtils.createXmlObject(soapSchemaXmlResource); soapSchema = XmlBeans.loadXsd(new XmlObject[]{soapSchemaXml}); URL soapEncodingXmlResource = ResourceUtils.getResourceWithAbsolutePackagePath(getClass(), "/xsds/", "soapEncoding12.xsd"); soapEncodingXml = XmlUtils.createXmlObject(soapEncodingXmlResource); } catch (XmlException e) { throw new SoapBuilderException(e); } } public String getEncodingNamespace() { return "http://www.w3.org/2003/05/soap-encoding"; } public XmlObject getSoapEncodingSchema() throws XmlException, IOException { return soapEncodingXml; } public XmlObject getSoapEnvelopeSchema() throws XmlException, IOException { return soapSchemaXml; } public String getEnvelopeNamespace() { return Constants.SOAP12_ENVELOPE_NS; } public SchemaType getEnvelopeType() { return EnvelopeDocument.type; } public String toString() { return "SOAP 1.2"; } public static String quote(String str) { if (str == null) return str; if (str.length() < 2 || !str.startsWith("\"") || !str.endsWith("\"")) str = "\"" + str + "\""; return str; } public String getContentTypeHttpHeader(String encoding, String soapAction) { String result = getContentType(); if (encoding != null && encoding.trim().length() > 0) result += ";charset=" + encoding; if (StringUtils.isNotBlank(soapAction)) result += ";action=" + quote(soapAction); return result; } public String getSoapActionHeader(String soapAction) { // SOAP 1.2 has this in the contenttype return null; } public String getContentType() { return "application/soap+xml"; } public QName getBodyQName() { return bodyQName; } public QName getEnvelopeQName() { return envelopeQName; } public QName getHeaderQName() { return headerQName; } protected SchemaTypeLoader getSoapEnvelopeSchemaLoader() { return soapSchema; } public static QName getFaultQName() { return faultQName; } public SchemaType getFaultType() { return FaultDocument.type; } public String getName() { return "SOAP 1.2"; } public String getFaultDetailNamespace() { return getEnvelopeNamespace(); } } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/UrlSchemaLoader.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlOptions; import org.reficio.ws.SoapBuilderException; import java.net.URL; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. *

* Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base */ class UrlSchemaLoader implements SchemaLoader, DefinitionLoader { private String baseURI; public UrlSchemaLoader(String baseURI) { this.baseURI = baseURI; } public XmlObject loadXmlObject(String wsdlUrl, XmlOptions options) throws Exception { return XmlUtils.createXmlObject(new URL(wsdlUrl), options); } public String getBaseURI() { return baseURI; } public void setProgressInfo(String info) { throw new SoapBuilderException("Not Implemented"); } public boolean isAborted() { throw new SoapBuilderException("Not Implemented"); } public boolean abort() { throw new SoapBuilderException("Not Implemented"); } public void setNewBaseURI(String uri) { throw new SoapBuilderException("Not Implemented"); } public String getFirstNewURI() { throw new SoapBuilderException("Not Implemented"); } } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/WsdlContext.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.xmlbeans.SchemaTypeLoader; import javax.wsdl.Binding; import javax.wsdl.Definition; /** * @author: Tom Bujok (tom.bujok@gmail.com) *

* Reficio™ - Reestablish your software! * www.reficio.org */ class WsdlContext { private final SoapMessageBuilder builder; private final Binding binding; WsdlContext(SoapMessageBuilder builder, Binding binding) { this.builder = builder; this.binding = binding; } Definition getDefinition() { return builder.getDefinition(); } SoapVersion getSoapVersion() { return SoapMessageBuilder.getSoapVersion(binding); } boolean hasSchemaTypes() { return builder.getSchemaDefinitionWrapper().hasSchemaTypes(); } SchemaTypeLoader getSchemaTypeLoader() { return builder.getSchemaDefinitionWrapper().getSchemaTypeLoader(); } } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/WsdlSettings.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. * * Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base */ /** * WSDL related settings constants * * @author Emil.Breding */ interface WsdlSettings { public final static String CACHE_WSDLS = WsdlSettings.class.getSimpleName() + "@" + "cache-wsdls"; public final static String XML_GENERATION_TYPE_EXAMPLE_VALUE = WsdlSettings.class.getSimpleName() + "@" + "xml-generation-type-example-value"; public final static String XML_GENERATION_TYPE_COMMENT_TYPE = WsdlSettings.class.getSimpleName() + "@" + "xml-generation-type-comment-type"; public final static String XML_GENERATION_ALWAYS_INCLUDE_OPTIONAL_ELEMENTS = WsdlSettings.class.getSimpleName() + "@" + "xml-generation-always-include-optional-elements"; public final static String PRETTY_PRINT_RESPONSE_MESSAGES = WsdlSettings.class.getSimpleName() + "@" + "pretty-print-response-xml"; public final static String ATTACHMENT_PARTS = WsdlSettings.class.getSimpleName() + "@" + "attachment-parts"; public final static String ALLOW_INCORRECT_CONTENTTYPE = WsdlSettings.class.getSimpleName() + "@" + "allow-incorrect-contenttype"; public final static String ENABLE_MTOM = WsdlSettings.class.getSimpleName() + "@" + "enable-mtom"; public static final String SCHEMA_DIRECTORY = WsdlSettings.class.getSimpleName() + "@" + "schema-directory"; public final static String NAME_WITH_BINDING = WsdlSettings.class.getSimpleName() + "@" + "name-with-binding"; public final static String EXCLUDED_TYPES = WsdlSettings.class.getSimpleName() + "@" + "excluded-types"; public final static String STRICT_SCHEMA_TYPES = WsdlSettings.class.getSimpleName() + "@" + "strict-schema-types"; public final static String COMPRESSION_LIMIT = WsdlSettings.class.getSimpleName() + "@" + "compression-limit"; public final static String PRETTY_PRINT_PROJECT_FILES = WsdlSettings.class.getSimpleName() + "@" + "pretty-print-project-files"; public static final String XML_GENERATION_SKIP_COMMENTS = WsdlSettings.class.getSimpleName() + "@" + "xml-generation-skip-comments"; public final static String TRIM_WSDL = WsdlSettings.class.getSimpleName() + "@" + "trim-wsdl"; } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/WsdlUtils.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import javax.wsdl.*; import javax.wsdl.extensions.ExtensibilityElement; import javax.wsdl.extensions.mime.MIMEContent; import javax.wsdl.extensions.mime.MIMEMultipartRelated; import javax.wsdl.extensions.mime.MIMEPart; import javax.wsdl.extensions.soap.*; import javax.wsdl.extensions.soap12.*; import javax.xml.XMLConstants; import javax.xml.namespace.QName; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. * * Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base */ /** * Wsdl-related tools * * @author Ole.Matzura */ @SuppressWarnings("unchecked") class WsdlUtils { private final static Logger log = Logger.getLogger(WsdlUtils.class); public static T getExtensiblityElement(List list, Class clazz) { List elements = getExtensiblityElements(list, clazz); return elements.isEmpty() ? null : elements.get(0); } public static List getExtensiblityElements(List list, Class clazz) { List result = new ArrayList(); for (Iterator i = list.iterator(); i.hasNext(); ) { T elm = i.next(); if (clazz.isAssignableFrom(elm.getClass())) { result.add(elm); } } return result; } public static Binding findBindingForOperation(Definition definition, BindingOperation bindingOperation) { Map services = definition.getAllServices(); Iterator s = services.values().iterator(); while (s.hasNext()) { Map ports = s.next().getPorts(); Iterator p = ports.values().iterator(); while (p.hasNext()) { Binding binding = p.next().getBinding(); List bindingOperations = binding.getBindingOperations(); for (Iterator iter = bindingOperations.iterator(); iter.hasNext(); ) { BindingOperation op = (BindingOperation) iter.next(); if (op.getName().equals(bindingOperation.getName())) return binding; } } } Map bindings = definition.getAllBindings(); Iterator names = bindings.keySet().iterator(); while (names.hasNext()) { Binding binding = definition.getBinding(names.next()); List bindingOperations = binding.getBindingOperations(); for (Iterator iter = bindingOperations.iterator(); iter.hasNext(); ) { BindingOperation op = (BindingOperation) iter.next(); if (op.getName().equals(bindingOperation.getName())) return binding; } } return null; } public static boolean isInputSoapEncoded(BindingOperation bindingOperation) { if (bindingOperation == null) return false; BindingInput bindingInput = bindingOperation.getBindingInput(); if (bindingInput == null) return false; SOAPBody soapBody = WsdlUtils.getExtensiblityElement(bindingInput.getExtensibilityElements(), SOAPBody.class); if (soapBody != null) { return soapBody.getUse() != null && soapBody.getUse().equalsIgnoreCase("encoded") && (soapBody.getEncodingStyles() == null || soapBody.getEncodingStyles().contains( "http://schemas.xmlsoap.org/soap/encoding/")); } SOAP12Body soap12Body = WsdlUtils.getExtensiblityElement(bindingInput.getExtensibilityElements(), SOAP12Body.class); if (soap12Body != null) { return soap12Body.getUse() != null && soap12Body.getUse().equalsIgnoreCase("encoded") && (soap12Body.getEncodingStyle() == null || soap12Body.getEncodingStyle().equals( "http://www.w3.org/2001/12/soap-encoding")); } return false; } public static boolean isOutputSoapEncoded(BindingOperation bindingOperation) { if (bindingOperation == null) return false; BindingOutput bindingOutput = bindingOperation.getBindingOutput(); if (bindingOutput == null) return false; SOAPBody soapBody = WsdlUtils.getExtensiblityElement(bindingOutput.getExtensibilityElements(), SOAPBody.class); if (soapBody != null) { return soapBody.getUse() != null && soapBody.getUse().equalsIgnoreCase("encoded") && (soapBody.getEncodingStyles() == null || soapBody.getEncodingStyles().contains( "http://schemas.xmlsoap.org/soap/encoding/")); } SOAP12Body soap12Body = WsdlUtils.getExtensiblityElement(bindingOutput.getExtensibilityElements(), SOAP12Body.class); if (soap12Body != null) { return soap12Body.getUse() != null && soap12Body.getUse().equalsIgnoreCase("encoded") && (soap12Body.getEncodingStyle() == null || soap12Body.getEncodingStyle().equals( "http://schemas.xmlsoap.org/soap/encoding/")); } return false; } public static boolean isRpc(Definition definition, BindingOperation bindingOperation) { SOAPOperation soapOperation = WsdlUtils.getExtensiblityElement(bindingOperation.getExtensibilityElements(), SOAPOperation.class); if (soapOperation != null && soapOperation.getStyle() != null) return soapOperation.getStyle().equalsIgnoreCase("rpc"); SOAP12Operation soap12Operation = WsdlUtils.getExtensiblityElement(bindingOperation.getExtensibilityElements(), SOAP12Operation.class); if (soap12Operation != null && soap12Operation.getStyle() != null) return soap12Operation.getStyle().equalsIgnoreCase("rpc"); Binding binding = findBindingForOperation(definition, bindingOperation); if (binding == null) { log.error("Failed to find binding for operation [" + bindingOperation.getName() + "] in definition [" + definition.getDocumentBaseURI() + "]"); return false; } return isRpc(binding); } public static boolean isRpc(Binding binding) { SOAPBinding soapBinding = WsdlUtils .getExtensiblityElement(binding.getExtensibilityElements(), SOAPBinding.class); if (soapBinding != null) return "rpc".equalsIgnoreCase(soapBinding.getStyle()); SOAP12Binding soap12Binding = WsdlUtils.getExtensiblityElement(binding.getExtensibilityElements(), SOAP12Binding.class); if (soap12Binding != null) return "rpc".equalsIgnoreCase(soap12Binding.getStyle()); return false; } public static boolean isOneWay(BindingOperation operation) { return operation.getOperation().getStyle().equals(OperationType.ONE_WAY); } /** * Returns a list of parts for the specifed operation, either as specified in * body or all */ public static Part[] getInputParts(BindingOperation operation) { List result = new ArrayList(); Input input = operation.getOperation().getInput(); if (input == null || operation.getBindingInput() == null) return new Part[0]; Message msg = input.getMessage(); if (msg != null) { SOAPBody soapBody = WsdlUtils.getExtensiblityElement(operation.getBindingInput().getExtensibilityElements(), SOAPBody.class); if (soapBody == null || soapBody.getParts() == null) { SOAP12Body soap12Body = WsdlUtils.getExtensiblityElement(operation.getBindingInput() .getExtensibilityElements(), SOAP12Body.class); if (soap12Body == null || soap12Body.getParts() == null) { if (msg != null) result.addAll(msg.getOrderedParts(null)); } else { Iterator i = soap12Body.getParts().iterator(); while (i.hasNext()) { String partName = (String) i.next(); Part part = msg.getPart(partName); result.add(part); } } } else { Iterator i = soapBody.getParts().iterator(); while (i.hasNext()) { String partName = (String) i.next(); Part part = msg.getPart(partName); result.add(part); } } } else { } return result.toArray(new Part[result.size()]); } public static boolean isAttachmentInputPart(Part part, BindingOperation operation) { return getInputMultipartContent(part, operation).length > 0; } public static boolean isAttachmentOutputPart(Part part, BindingOperation operation) { return getOutputMultipartContent(part, operation).length > 0; } public static MIMEContent[] getOutputMultipartContent(Part part, BindingOperation operation) { BindingOutput output = operation.getBindingOutput(); if (output == null) return new MIMEContent[0]; MIMEMultipartRelated multipartOutput = WsdlUtils.getExtensiblityElement(output.getExtensibilityElements(), MIMEMultipartRelated.class); return getContentParts(part, multipartOutput); } public static MIMEContent[] getInputMultipartContent(Part part, BindingOperation operation) { BindingInput bindingInput = operation.getBindingInput(); if (bindingInput == null) return new MIMEContent[0]; MIMEMultipartRelated multipartInput = WsdlUtils.getExtensiblityElement(bindingInput.getExtensibilityElements(), MIMEMultipartRelated.class); return getContentParts(part, multipartInput); } public static MIMEContent[] getContentParts(Part part, MIMEMultipartRelated multipart) { List result = new ArrayList(); if (multipart != null) { List parts = multipart.getMIMEParts(); for (int c = 0; c < parts.size(); c++) { List contentParts = WsdlUtils.getExtensiblityElements(parts.get(c) .getExtensibilityElements(), MIMEContent.class); for (MIMEContent content : contentParts) { if (content.getPart().equals(part.getName())) result.add(content); } } } return result.toArray(new MIMEContent[result.size()]); } public static Part[] getFaultParts(BindingOperation bindingOperation, String faultName) throws Exception { List result = new ArrayList(); BindingFault bindingFault = bindingOperation.getBindingFault(faultName); SOAPFault soapFault = WsdlUtils.getExtensiblityElement(bindingFault.getExtensibilityElements(), SOAPFault.class); Operation operation = bindingOperation.getOperation(); if (soapFault != null && soapFault.getName() != null) { Fault fault = operation.getFault(soapFault.getName()); if (fault == null) throw new Exception("Missing Fault [" + soapFault.getName() + "] in operation [" + operation.getName() + "]"); result.addAll(fault.getMessage().getOrderedParts(null)); } else { SOAP12Fault soap12Fault = WsdlUtils.getExtensiblityElement(bindingFault.getExtensibilityElements(), SOAP12Fault.class); if (soap12Fault != null && soap12Fault.getName() != null) { Fault fault = operation.getFault(soap12Fault.getName()); if (fault != null && fault.getMessage() != null) result.addAll(fault.getMessage().getOrderedParts(null)); } else { Fault fault = operation.getFault(faultName); if (fault != null && fault.getMessage() != null) result.addAll(fault.getMessage().getOrderedParts(null)); } } return result.toArray(new Part[result.size()]); } public static Part[] getOutputParts(BindingOperation operation) { BindingOutput bindingOutput = operation.getBindingOutput(); if (bindingOutput == null) return new Part[0]; List result = new ArrayList(); Output output = operation.getOperation().getOutput(); if (output == null) return new Part[0]; Message msg = output.getMessage(); if (msg != null) { SOAPBody soapBody = WsdlUtils .getExtensiblityElement(bindingOutput.getExtensibilityElements(), SOAPBody.class); if (soapBody == null || soapBody.getParts() == null) { SOAP12Body soap12Body = WsdlUtils.getExtensiblityElement(bindingOutput.getExtensibilityElements(), SOAP12Body.class); if (soap12Body == null || soap12Body.getParts() == null) { result.addAll(msg.getOrderedParts(null)); } else { Iterator i = soap12Body.getParts().iterator(); while (i.hasNext()) { String partName = (String) i.next(); Part part = msg.getPart(partName); result.add(part); } } } else { Iterator i = soapBody.getParts().iterator(); while (i.hasNext()) { String partName = (String) i.next(); Part part = msg.getPart(partName); result.add(part); } } } else { log.warn("Missing output message for binding operation [" + operation.getName() + "]"); } return result.toArray(new Part[result.size()]); } public static String getSoapEndpoint(Port port) { SOAPAddress soapAddress = WsdlUtils.getExtensiblityElement(port.getExtensibilityElements(), SOAPAddress.class); if (soapAddress != null && StringUtils.isNotBlank(soapAddress.getLocationURI())) { try { return URLDecoder.decode(soapAddress.getLocationURI(), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return soapAddress.getLocationURI(); } } SOAP12Address soap12Address = WsdlUtils.getExtensiblityElement(port.getExtensibilityElements(), SOAP12Address.class); if (soap12Address != null && StringUtils.isNotBlank(soap12Address.getLocationURI())) { try { return URLDecoder.decode(soap12Address.getLocationURI(), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return soap12Address.getLocationURI(); } } return null; } public static boolean replaceSoapEndpoint(Port port, String endpoint) { SOAPAddress soapAddress = WsdlUtils.getExtensiblityElement(port.getExtensibilityElements(), SOAPAddress.class); if (soapAddress != null) { soapAddress.setLocationURI(endpoint); return true; } SOAP12Address soap12Address = WsdlUtils.getExtensiblityElement(port.getExtensibilityElements(), SOAP12Address.class); if (soap12Address != null) { soap12Address.setLocationURI(endpoint); return true; } return false; } public static String getSoapBodyNamespace(List list) { SOAPBody soapBody = WsdlUtils.getExtensiblityElement(list, SOAPBody.class); if (soapBody != null) return soapBody.getNamespaceURI(); SOAP12Body soap12Body = WsdlUtils.getExtensiblityElement(list, SOAP12Body.class); if (soap12Body != null) return soap12Body.getNamespaceURI(); return null; } /** * A SOAP-Header wrapper * * @author ole.matzura */ public interface SoapHeader { public QName getMessage(); public String getPart(); } /** * SOAP 1.1 Header implementation * * @author ole.matzura */ public static class Soap11Header implements SoapHeader { private final SOAPHeader soapHeader; public Soap11Header(SOAPHeader soapHeader) { this.soapHeader = soapHeader; } public QName getMessage() { return soapHeader.getMessage(); } public String getPart() { return soapHeader.getPart(); } } /** * SOAP 1.2 Header implementation * * @author ole.matzura */ public static class Soap12Header implements SoapHeader { private final SOAP12Header soapHeader; public Soap12Header(SOAP12Header soapHeader) { this.soapHeader = soapHeader; } public QName getMessage() { return soapHeader.getMessage(); } public String getPart() { return soapHeader.getPart(); } } public static List getSoapHeaders(List list) { List result = new ArrayList(); List soapHeaders = WsdlUtils.getExtensiblityElements(list, SOAPHeader.class); if (soapHeaders != null && !soapHeaders.isEmpty()) { for (SOAPHeader header : soapHeaders) result.add(new Soap11Header(header)); } else { List soap12Headers = WsdlUtils.getExtensiblityElements(list, SOAP12Header.class); if (soap12Headers != null && !soap12Headers.isEmpty()) { for (SOAP12Header header : soap12Headers) result.add(new Soap12Header(header)); } } return result; } public static BindingOperation findBindingOperation(Binding binding, String bindingOperationName, String inputName, String outputName) { if (binding == null) return null; if (inputName == null) inputName = ":none"; if (outputName == null) outputName = ":none"; BindingOperation result = binding.getBindingOperation(bindingOperationName, inputName, outputName); if (result == null && (inputName.equals(":none") || outputName.equals(":none"))) { // fall back to this behaviour for WSDL4j 1.5.0 compatibility result = binding.getBindingOperation(bindingOperationName, inputName.equals(":none") ? null : inputName, outputName.equals(":none") ? null : outputName); } return result; } public static String getTargetNamespace(Definition definition) { return definition.getTargetNamespace() == null ? XMLConstants.NULL_NS_URI : definition.getTargetNamespace(); } } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/WsdlValidator.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.apache.xmlbeans.*; import org.w3c.dom.Element; import org.w3c.dom.NodeList; import javax.wsdl.Binding; import javax.wsdl.BindingFault; import javax.wsdl.BindingOperation; import javax.wsdl.Part; import javax.xml.namespace.QName; import java.util.*; /** * Class for validating SOAP requests/responses against their definition and * schema, requires that the messages follow basic-profile requirements * * @author Ole.Matzura */ class WsdlValidator { private final static Logger log = Logger.getLogger(WsdlValidator.class); private final WsdlContext wsdlContext; WsdlValidator(SoapMessageBuilder builder, Binding binding) { this.wsdlContext = new WsdlContext(builder, binding); } List assertRequest(BindingOperation bindingOperation, String message, boolean strict) { List errors = new ArrayList(); try { validateXml(message, errors); wsdlContext.getSoapVersion().validateSoapEnvelope(message, errors); if (errors.isEmpty()) { if (bindingOperation == null) { errors.add(XmlError.forMessage("Missing operation [" + bindingOperation.getName() + "] in wsdl definition")); } else { Part[] inputParts = WsdlUtils.getInputParts(bindingOperation); validateMessage(message, bindingOperation, inputParts, errors, false, strict); // ATTACHMENTS ARE SKIPPED FOR NOW // validateInputAttachments(request, errors, bindingOperation, // inputParts); } } } catch (Exception e) { errors.add(XmlError.forMessage(e.getMessage())); } return convertErrors(errors); } List assertResponse(BindingOperation bindingOperation, String message, boolean strict) { List errors = new ArrayList(); try { validateXml(message, errors); if (StringUtils.isBlank(message)) { if (!WsdlUtils.isOneWay(bindingOperation)) { errors.add(XmlError.forMessage("Response is missing or empty")); } } else { wsdlContext.getSoapVersion().validateSoapEnvelope(message, errors); if (errors.isEmpty()) { if (bindingOperation == null) { errors.add(XmlError.forMessage("Missing operation [" + bindingOperation.getName() + "] in wsdl definition")); } else { Part[] outputParts = WsdlUtils.getOutputParts(bindingOperation); validateMessage(message, bindingOperation, outputParts, errors, true, strict); } } } } catch (Exception e) { e.printStackTrace(); errors.add(XmlError.forMessage(e.getMessage())); } return convertErrors(errors); } // ----------------------------------------------- // UGLY INTERNAL API // ----------------------------------------------- @SuppressWarnings("unchecked") private void validateXml(String request, List errors) { try { XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setLoadLineNumbers(); xmlOptions.setErrorListener(errors); xmlOptions.setLoadLineNumbers(XmlOptions.LOAD_LINE_NUMBERS_END_ELEMENT); XmlUtils.createXmlObject(request, xmlOptions); } catch (XmlException e) { if (e.getErrors() != null) errors.addAll(e.getErrors()); errors.add(XmlError.forMessage(e.getMessage())); } catch (Exception e) { errors.add(XmlError.forMessage(e.getMessage())); } } private List convertErrors(List errors) { if (errors.size() > 0) { List response = new ArrayList(); for (Iterator i = errors.iterator(); i.hasNext(); ) { XmlError error = i.next(); if (error instanceof XmlValidationError) { XmlValidationError e = ((XmlValidationError) error); QName offendingQName = e.getOffendingQName(); if (offendingQName != null) { if (offendingQName.equals(new QName(wsdlContext.getSoapVersion().getEnvelopeNamespace(), "encodingStyle"))) { log.debug("ignoring encodingStyle validation.."); continue; } else if (offendingQName.equals(new QName(wsdlContext.getSoapVersion().getEnvelopeNamespace(), "mustUnderstand"))) { log.debug("ignoring mustUnderstand validation.."); continue; } } } AssertionError assertionError = new AssertionError(error); if (!response.contains(assertionError)) response.add(assertionError); } return new ArrayList(response); } return new ArrayList(); } @SuppressWarnings("unchecked") private void validateMessage(String message, BindingOperation bindingOperation, Part[] parts, List errors, boolean isResponse, boolean strict) { try { if (!wsdlContext.hasSchemaTypes()) { errors.add(XmlError.forMessage("Missing schema types for message")); } else { if (!WsdlUtils.isOutputSoapEncoded(bindingOperation)) { XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setLoadLineNumbers(); xmlOptions.setLoadLineNumbers(XmlOptions.LOAD_LINE_NUMBERS_END_ELEMENT); XmlObject xml = XmlUtils.createXmlObject(message, xmlOptions); XmlObject[] paths = xml.selectPath("declare namespace env='" + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "';" + "$this/env:Envelope/env:Body/env:Fault"); if (paths.length > 0) { validateSoapFault(bindingOperation, paths[0], errors); } else if (WsdlUtils.isRpc(wsdlContext.getDefinition(), bindingOperation)) { validateRpcLiteral(bindingOperation, parts, xml, errors, isResponse, strict); } else { validateDocLiteral(bindingOperation, parts, xml, errors, isResponse, strict); } // ATTACHMENTS SKIPPED FOR NOW // if( isResponse ) // validateOutputAttachments( messageExchange, xml, errors, bindingOperation, parts ); // else // validateInputAttachments( messageExchange, errors, bindingOperation, parts ); } else { errors.add(XmlError.forMessage("Validation of SOAP-Encoded messages not supported")); } } } catch (XmlException e) { if (e.getErrors() != null) errors.addAll(e.getErrors()); errors.add(XmlError.forMessage(e.getMessage())); } catch (Exception e) { errors.add(XmlError.forMessage(e.getMessage())); } } private void validateDocLiteral(BindingOperation bindingOperation, Part[] parts, XmlObject msgXml, List errors, boolean isResponse, boolean strict) throws Exception { Part part = null; // start by finding body part for (int c = 0; c < parts.length; c++) { // content part? if ((isResponse && !WsdlUtils.isAttachmentOutputPart(parts[c], bindingOperation)) || (!isResponse && !WsdlUtils.isAttachmentInputPart(parts[c], bindingOperation))) { // already found? if (part != null) { if (strict) { errors.add(XmlError.forMessage("DocLiteral message must contain 1 body part definition")); } return; } part = parts[c]; } } QName elementName = part.getElementName(); if (elementName != null) { // just check for correct message element, other elements are avoided // (should create an error) XmlObject[] paths = msgXml.selectPath("declare namespace env='" + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "';" + "declare namespace ns='" + elementName.getNamespaceURI() + "';" + "$this/env:Envelope/env:Body/ns:" + elementName.getLocalPart()); if (paths.length == 1) { SchemaGlobalElement elm = wsdlContext.getSchemaTypeLoader().findElement(elementName); if (elm != null) { validateMessageBody(errors, elm.getType(), paths[0]); // ensure no other elements in body NodeList children = XmlUtils.getChildElements((Element) paths[0].getDomNode().getParentNode()); for (int d = 0; d < children.getLength(); d++) { QName childName = XmlUtils.getQName(children.item(d)); if (!elementName.equals(childName)) { XmlCursor cur = paths[0].newCursor(); cur.toParent(); cur.toChild(childName); errors.add(XmlError.forCursor("Invalid element [" + childName + "] in SOAP Body", cur)); cur.dispose(); } } } else { errors.add(XmlError.forMessage("Missing part type [" + elementName + "] in associated schema")); } } else { errors.add(XmlError.forMessage("Missing message part with name [" + elementName + "]")); } } else if (part.getTypeName() != null) { QName typeName = part.getTypeName(); XmlObject[] paths = msgXml.selectPath("declare namespace env='" + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "';" + "declare namespace ns='" + typeName.getNamespaceURI() + "';" + "$this/env:Envelope/env:Body/ns:" + part.getName()); if (paths.length == 1) { SchemaType type = wsdlContext.getSchemaTypeLoader().findType(typeName); if (type != null) { validateMessageBody(errors, type, paths[0]); // XmlObject obj = paths[0].copy().changeType( type ); // obj.validate( new XmlOptions().setErrorListener( errors )); } else errors.add(XmlError.forMessage("Missing part type in associated schema")); } else errors.add(XmlError.forMessage("Missing message part with name:type [" + part.getName() + ":" + typeName + "]")); } } private void validateMessageBody(List errors, SchemaType type, XmlObject msg) throws XmlException { // need to create new body element of correct type from xml text // since we want to retain line-numbers XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setLoadLineNumbers(); xmlOptions.setLoadLineNumbers(XmlOptions.LOAD_LINE_NUMBERS_END_ELEMENT); XmlCursor cur = msg.newCursor(); Map map = new HashMap(); while (cur.hasNextToken()) { if (cur.toNextToken().isNamespace()) map.put(cur.getName().getLocalPart(), cur.getTextValue()); } xmlOptions.setUseDefaultNamespace(); xmlOptions.setSaveOuter(); // problem: prefixes might get redefined/changed when saving which can // cause xsi:type refs to // reference wrong/non-existing namespace.. solution would probably be to // manually walk through document and // update xsi:type refs with new prefix. The setUseDefaultNamespace() // above helps here but is not a definitive fix String xmlText = msg.copy().changeType(type).xmlText(xmlOptions); xmlOptions.setLoadAdditionalNamespaces(map); XmlObject obj = type.getTypeSystem().parse(xmlText, type, xmlOptions); obj = obj.changeType(type); // create internal error list ArrayList list = new ArrayList(); xmlOptions = new XmlOptions(); xmlOptions.setErrorListener(list); xmlOptions.setValidateTreatLaxAsSkip(); try { obj.validate(xmlOptions); } catch (Exception e) { log.error("Internal error", e); list.add("Internal Error - see error log for details - [" + e + "]"); } // transfer errors for "real" line numbers for (int c = 0; c < list.size(); c++) { XmlError error = (XmlError) list.get(c); if (error instanceof XmlValidationError) { XmlValidationError validationError = ((XmlValidationError) error); if (wsdlContext.getSoapVersion().shouldIgnore(validationError)) continue; // ignore cid: related errors if (validationError.getErrorCode().equals("base64Binary") || validationError.getErrorCode().equals("hexBinary")) { XmlCursor cursor = validationError.getCursorLocation(); if (cursor.toParent()) { String text = cursor.getTextValue(); // special handling for soapui/MTOM -> add option for // disabling? if (text.startsWith("cid:") || text.startsWith("file:")) { // ignore continue; } } } } int line = error.getLine() == -1 ? 0 : error.getLine() - 1; errors.add(XmlError.forLocation(error.getMessage(), error.getSourceName(), getLine(msg) + line, error.getColumn(), error.getOffset())); } } private int getLine(XmlObject object) { List list = new ArrayList(); object.newCursor().getAllBookmarkRefs(list); for (int c = 0; c < list.size(); c++) { if (list.get(c) instanceof XmlLineNumber) { return ((XmlLineNumber) list.get(c)).getLine(); } } return -1; } private void validateRpcLiteral(BindingOperation bindingOperation, Part[] parts, XmlObject msgXml, List errors, boolean isResponse, boolean strict) throws Exception { if (parts.length == 0) return; XmlObject[] bodyParts = getRpcBodyPart(bindingOperation, msgXml, isResponse); if (bodyParts.length != 1) { errors.add(XmlError.forMessage("Missing message wrapper element [" + WsdlUtils.getTargetNamespace(wsdlContext.getDefinition()) + "@" + bindingOperation.getName() + (isResponse ? "Response" : ""))); } else { XmlObject wrapper = bodyParts[0]; for (int i = 0; i < parts.length; i++) { Part part = parts[i]; // skip attachment parts if (isResponse) { if (WsdlUtils.isAttachmentOutputPart(part, bindingOperation)) continue; } else { if (WsdlUtils.isAttachmentInputPart(part, bindingOperation)) continue; } // find part in message XmlObject[] children = wrapper.selectChildren(new QName(part.getName())); // not found? if (children.length != 1) { // try element name (loophole in basic-profile spec?) QName elementName = part.getElementName(); if (elementName != null) { bodyParts = msgXml.selectPath("declare namespace env='" + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "';" + "declare namespace ns='" + wsdlContext.getDefinition().getTargetNamespace() + "';" + "declare namespace ns2='" + elementName.getNamespaceURI() + "';" + "$this/env:Envelope/env:Body/ns:" + bindingOperation.getName() + (isResponse ? "Response" : "") + "/ns2:" + elementName.getLocalPart()); if (bodyParts.length == 1) { SchemaGlobalElement elm = wsdlContext.getSchemaTypeLoader().findElement(elementName); if (elm != null) { validateMessageBody(errors, elm.getType(), bodyParts[0]); } else errors.add(XmlError.forMessage("Missing part type in associated schema for [" + elementName + "]")); } else errors.add(XmlError.forMessage("Missing message part with name [" + elementName + "]")); } else { errors.add(XmlError.forMessage("Missing message part [" + part.getName() + "]")); } } else { QName typeName = part.getTypeName(); SchemaType type = wsdlContext.getSchemaTypeLoader().findType(typeName); if (type != null) { validateMessageBody(errors, type, children[0]); } else { errors.add(XmlError.forMessage("Missing type in associated schema for part [" + part.getName() + "]")); } } } } } private XmlObject[] getRpcBodyPart(BindingOperation bindingOperation, XmlObject msgXml, boolean isResponse) throws Exception { // rpc requests should use the operation name as root element and soapbind // namespaceuri attribute as ns String ns = WsdlUtils.getSoapBodyNamespace(isResponse ? bindingOperation.getBindingOutput() .getExtensibilityElements() : bindingOperation.getBindingInput().getExtensibilityElements()); if (ns == null || ns.trim().length() == 0) ns = WsdlUtils.getTargetNamespace(wsdlContext.getDefinition()); // get root element XmlObject[] paths = msgXml.selectPath("declare namespace env='" + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "';" + "declare namespace ns='" + ns + "';" + "$this/env:Envelope/env:Body/ns:" + bindingOperation.getName() + (isResponse ? "Response" : "")); return paths; } @SuppressWarnings("unchecked") private void validateSoapFault(BindingOperation bindingOperation, XmlObject msgXml, List errors) throws Exception { Map faults = bindingOperation.getBindingFaults(); Iterator i = faults.values().iterator(); // create internal error list List list = new ArrayList(); XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setErrorListener(list); xmlOptions.setValidateTreatLaxAsSkip(); msgXml.validate(xmlOptions); for (Object o : list) { if (o instanceof XmlError) errors.add((XmlError) o); else errors.add(XmlError.forMessage(o.toString())); } while (i.hasNext()) { BindingFault bindingFault = i.next(); String faultName = bindingFault.getName(); Part[] faultParts = WsdlUtils.getFaultParts(bindingOperation, faultName); if (faultParts.length == 0) { log.warn("Missing fault parts in wsdl for fault [" + faultName + "] in bindingOperation [" + bindingOperation.getName() + "]"); continue; } if (faultParts.length != 1) { log.info("Too many fault parts in wsdl for fault [" + faultName + "] in bindingOperation [" + bindingOperation.getName() + "]"); continue; } Part part = faultParts[0]; QName elementName = part.getElementName(); if (elementName != null) { XmlObject[] paths = msgXml.selectPath("declare namespace env='" + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "'; declare namespace flt='" + wsdlContext.getSoapVersion().getFaultDetailNamespace() + "';" + "declare namespace ns='" + elementName.getNamespaceURI() + "';" + "//env:Fault/flt:detail/ns:" + elementName.getLocalPart()); if (paths.length == 1) { SchemaGlobalElement elm = wsdlContext.getSchemaTypeLoader().findElement(elementName); if (elm != null) { validateMessageBody(errors, elm.getType(), paths[0]); } else errors.add(XmlError.forMessage("Missing fault part element [" + elementName + "] for fault [" + part.getName() + "] in associated schema")); return; } } // this is not allowed by Basic Profile.. remove? else if (part.getTypeName() != null) { QName typeName = part.getTypeName(); XmlObject[] paths = msgXml.selectPath("declare namespace env='" + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "'; declare namespace flt='" + wsdlContext.getSoapVersion().getFaultDetailNamespace() + "';" + "declare namespace ns='" + typeName.getNamespaceURI() + "';" + "//env:Fault/flt:detail/ns:" + part.getName()); if (paths.length == 1) { SchemaType type = wsdlContext.getSchemaTypeLoader().findType(typeName); if (type != null) { validateMessageBody(errors, type, paths[0]); } else errors.add(XmlError.forMessage("Missing fault part type [" + typeName + "] for fault [" + part.getName() + "] in associated schema")); return; } } } // if we get here, no matching fault was found.. this is not an error but // should be warned.. XmlObject[] paths = msgXml.selectPath("declare namespace env='" + wsdlContext.getSoapVersion().getEnvelopeNamespace() + "'; declare namespace flt='" + wsdlContext.getSoapVersion().getFaultDetailNamespace() + "';//env:Fault/flt:detail"); if (paths.length == 0) log.warn("Missing matching Fault in wsdl for bindingOperation [" + bindingOperation.getName() + "]"); else { String xmlText = paths[0].xmlText(new XmlOptions().setSaveOuter()); log.warn("Missing matching Fault in wsdl for Fault Detail element [" + XmlUtils.removeUnneccessaryNamespaces(xmlText) + "] in bindingOperation [" + bindingOperation.getName() + "]"); } } // ATTACHMENTS ARE SKIPPED FOR NOW // private void validateInputAttachments( WsdlMessageExchange messageExchange, List errors, // BindingOperation bindingOperation, Part[] inputParts ) // { // for( Part part : inputParts ) // { // MIMEContent[] contents = WsdlUtils.getInputMultipartContent( part, bindingOperation ); // if( contents.length == 0 ) // continue; // // Attachment[] attachments = messageExchange.getRequestAttachmentsForPart( part.getName() ); // if( attachments.length == 0 ) // { // errors.add( XmlError.forMessage( "Missing attachment for part [" + part.getName() + "]" ) ); // } // else if( attachments.length == 1 ) // { // Attachment attachment = attachments[0]; // String types = ""; // for( MIMEContent content : contents ) // { // String type = content.getType(); // if( type.equals( attachment.getContentType() ) || type.toUpperCase().startsWith( "MULTIPART" ) ) // { // types = null; // break; // } // if( types.length() > 0 ) // types += ","; // // types += type; // } // // if( types != null ) // { // String msg = "Missing attachment for part [" + part.getName() + "] with content-type [" + types + "]," // + " content type is [" + attachment.getContentType() + "]"; // // if(ALLOW_INCORRECT_CONTENT_TYPE) // log.warn( msg ); // else // errors.add( XmlError.forMessage( msg ) ); // } // } // else // { // String types = ""; // for( MIMEContent content : contents ) // { // String type = content.getType(); // if( type.toUpperCase().startsWith( "MULTIPART" ) ) // { // types = null; // break; // } // if( types.length() > 0 ) // types += ","; // // types += type; // } // // if( types == null ) // { // String msg = "Too many attachments for part [" + part.getName() + "] with content-type [" + types + "]"; // if(ALLOW_INCORRECT_CONTENT_TYPE) // log.warn( msg ); // else // errors.add( XmlError.forMessage( msg ) ); // } // } // // if( attachments.length > 0 ) // validateAttachmentsReadability( errors, attachments ); // } // } // // private void validateOutputAttachments( WsdlMessageExchange messageExchange, XmlObject xml, List errors, // BindingOperation bindingOperation, Part[] outputParts ) throws Exception // { // for( Part part : outputParts ) // { // MIMEContent[] contents = WsdlUtils.getOutputMultipartContent( part, bindingOperation ); // if( contents.length == 0 ) // continue; // // Attachment[] attachments = messageExchange.getResponseAttachmentsForPart( part.getName() ); // // // check for rpc // if( attachments.length == 0 && WsdlUtils.isRpc( wsdlContext.getDefinition(), bindingOperation ) ) // { // XmlObject[] rpcBodyPart = getRpcBodyPart( bindingOperation, xml, true ); // if( rpcBodyPart.length == 1 ) // { // XmlObject[] children = rpcBodyPart[0].selectChildren( new QName( part.getName() ) ); // if( children.length == 1 ) // { // String href = ( ( Element )children[0].getDomNode() ).getAttribute( "href" ); // if( href != null ) // { // if( href.startsWith( "cid:" ) ) // href = href.substring( 4 ); // // attachments = messageExchange.getResponseAttachmentsForPart( href ); // } // } // } // } // // if( attachments.length == 0 ) // { // errors.add( XmlError.forMessage( "Missing attachment for part [" + part.getName() + "]" ) ); // } // else if( attachments.length == 1 ) // { // Attachment attachment = attachments[0]; // String types = ""; // for( MIMEContent content : contents ) // { // String type = content.getType(); // if( type.equals( attachment.getContentType() ) || type.toUpperCase().startsWith( "MULTIPART" ) ) // { // types = null; // break; // } // // if( types.length() > 0 ) // types += ","; // // types += type; // } // // if( types != null ) // { // String msg = "Missing attachment for part [" + part.getName() + "] with content-type [" + types // + "], content type is [" + attachment.getContentType() + "]"; // // if(ALLOW_INCORRECT_CONTENT_TYPE) // log.warn( msg ); // else // errors.add( XmlError.forMessage( msg ) ); // } // } // else // { // String types = ""; // for( MIMEContent content : contents ) // { // String type = content.getType(); // if( type.toUpperCase().startsWith( "MULTIPART" ) ) // { // types = null; // break; // } // // if( types.length() > 0 ) // types += ","; // // types += type; // } // // if( types != null ) // { // String msg = "Too many attachments for part [" + part.getName() + "] with content-type [" + types + "]"; // // if(ALLOW_INCORRECT_CONTENT_TYPE) // log.warn( msg ); // else // errors.add( XmlError.forMessage( msg ) ); // } // } // // if( attachments.length > 0 ) // validateAttachmentsReadability( errors, attachments ); // } // } // // private void validateAttachmentsReadability( List errors, Attachment[] attachments ) // { // for( Attachment attachment : attachments ) // { // try // { // attachment.getInputStream(); // } // catch( Exception e ) // { // errors.add( XmlError.forMessage( e.toString() ) ); // } // } // } } ================================================ FILE: soap-legacy/src/main/java/org/reficio/ws/legacy/XmlUtils.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package org.reficio.ws.legacy; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlOptions; import org.w3c.dom.*; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.io.InputStream; import java.io.StringReader; import java.io.Writer; import java.net.URL; import java.util.*; /** * This class was extracted from the soapUI code base by centeractive ag in October 2011. * The main reason behind the extraction was to separate the code that is responsible * for the generation of the SOAP messages from the rest of the soapUI's code that is * tightly coupled with other modules, such as soapUI's graphical user interface, etc. * The goal was to create an open-source java project whose main responsibility is to * handle SOAP message generation and SOAP transmission purely on an XML level. *
* centeractive ag would like to express strong appreciation to SmartBear Software and * to the whole team of soapUI's developers for creating soapUI and for releasing its * source code under a free and open-source licence. centeractive ag extracted and * modifies some parts of the soapUI's code in good faith, making every effort not * to impair any existing functionality and to supplement it according to our * requirements, applying best practices of software design. * * Changes done: * - changing location in the package structure * - removal of dependencies and code parts that are out of scope of SOAP message generation * - minor fixes to make the class compile out of soapUI's code base * - adding utility method to handle XML-String from/to XML-Source transformation */ /** * General XML-related utilities */ @SuppressWarnings("deprecation") final class XmlUtils { private static DocumentBuilder documentBuilder; private final static Logger log = Logger.getLogger(XmlUtils.class); static synchronized public Document parse(InputStream in) { try { return ensureDocumentBuilder().parse(in); } catch (Exception e) { log.error("Error parsing InputStream; " + e.getMessage(), e); } return null; } static synchronized public Document parse(String fileName) throws IOException { try { return ensureDocumentBuilder().parse(fileName); } catch (SAXException e) { log.error("Error parsing fileName [" + fileName + "]; " + e.getMessage(), e); } return null; } static synchronized public Document parse(InputSource inputSource) throws IOException { try { return ensureDocumentBuilder().parse(inputSource); } catch (SAXException e) { throw new IOException(e.toString()); } } public static NodeList getChildElements(Element elm) { List list = new ArrayList(); NodeList nl = elm.getChildNodes(); for (int c = 0; c < nl.getLength(); c++) { Node item = nl.item(c); if (item.getParentNode() == elm && item.getNodeType() == Node.ELEMENT_NODE) list.add((Element) item); } return new ElementNodeList(list); } private final static class ElementNodeList implements NodeList { private final List list; public ElementNodeList(List list) { this.list = list; } public int getLength() { return list.size(); } public Node item(int index) { return list.get(index); } } public static String getChildElementText(Element elm, String name) { Element child = getFirstChildElement(elm, name); return child == null ? null : getElementText(child); } public static Element getFirstChildElement(Element elm) { return getFirstChildElement(elm, null); } static public String getElementText(Element elm) { Node node = elm.getFirstChild(); if (node != null && node.getNodeType() == Node.TEXT_NODE) return node.getNodeValue(); return null; } static public String getFragmentText(DocumentFragment elm) { Node node = elm.getFirstChild(); if (node != null && node.getNodeType() == Node.TEXT_NODE) return node.getNodeValue(); return null; } public static String getChildElementText(Element elm, String name, String defaultValue) { String result = getChildElementText(elm, name); return result == null ? defaultValue : result; } static public String getNodeValue(Node node) { if (node == null) return null; if (node.getNodeType() == Node.ELEMENT_NODE) return getElementText((Element) node); else if (node.getNodeType() == Node.DOCUMENT_FRAGMENT_NODE) return getFragmentText((DocumentFragment) node); else return node.getNodeValue(); } public static Element getFirstChildElement(Element elm, String name) { if (elm == null) return null; NodeList nl = elm.getChildNodes(); for (int c = 0; c < nl.getLength(); c++) { Node node = nl.item(c); if (node.getNodeType() == Node.ELEMENT_NODE && (name == null || node.getNodeName().equals(name))) return (Element) node; } return null; } public static Element getFirstChildElementIgnoreCase(Element elm, String name) { if (elm == null) return null; NodeList nl = elm.getChildNodes(); for (int c = 0; c < nl.getLength(); c++) { Node node = nl.item(c); if (node.getNodeType() == Node.ELEMENT_NODE && (name == null || node.getNodeName().equalsIgnoreCase(name))) return (Element) node; } return null; } public static Element getFirstChildElementNS(Element elm, String tns, String localName) { if (tns == null && localName == null) return getFirstChildElement(elm); if (tns == null || tns.length() == 0) return getFirstChildElement(elm, localName); NodeList nl = elm.getChildNodes(); for (int c = 0; c < nl.getLength(); c++) { Node node = nl.item(c); if (node.getNodeType() != Node.ELEMENT_NODE) continue; if (localName == null && tns.equals(node.getNamespaceURI())) return (Element) node; if (localName != null && tns.equals(node.getNamespaceURI()) && localName.equals(node.getLocalName())) return (Element) node; } return null; } public static String removeUnneccessaryNamespaces(String xml) { if (StringUtils.isBlank(xml)) { return xml; } XmlObject xmlObject = null; XmlCursor cursor = null; try { xmlObject = XmlObject.Factory.parse(xml); cursor = xmlObject.newCursor(); while (cursor.currentTokenType() != XmlCursor.TokenType.START && cursor.currentTokenType() != XmlCursor.TokenType.ENDDOC) { cursor.toNextToken(); } if (cursor.currentTokenType() == XmlCursor.TokenType.START) { Map nsMap = new HashMap(); cursor.getAllNamespaces(nsMap); nsMap.remove(cursor.getDomNode().getPrefix()); NamedNodeMap attributes = cursor.getDomNode().getAttributes(); for (int c = 0; attributes != null && c < attributes.getLength(); c++) { nsMap.remove(attributes.item(c).getPrefix()); } if (cursor.toFirstChild()) { while (cursor.getDomNode() != xmlObject.getDomNode()) { attributes = cursor.getDomNode().getAttributes(); for (int c = 0; attributes != null && c < attributes.getLength(); c++) { nsMap.remove(attributes.item(c).getPrefix()); } nsMap.remove(cursor.getDomNode().getPrefix()); cursor.toNextToken(); } } xml = xmlObject.xmlText(new XmlOptions().setSaveOuter().setSavePrettyPrint() .setSaveImplicitNamespaces(nsMap)); } } catch (XmlException e) { } finally { if (cursor != null) cursor.dispose(); } return xml; } private static DocumentBuilder ensureDocumentBuilder() { if (documentBuilder == null) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); documentBuilder = dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { log.error("Error creating DocumentBuilder; " + e.getMessage()); } } return documentBuilder; } public static XmlObject createXmlObject(String input, XmlOptions xmlOptions) throws XmlException { return XmlObject.Factory.parse(input, xmlOptions); } public static XmlObject createXmlObject(URL input, XmlOptions xmlOptions) throws XmlException { try { return XmlObject.Factory.parse(input, xmlOptions); } catch (Exception e) { throw new XmlException(e.toString()); } } public static XmlObject createXmlObject(String input) throws XmlException { return XmlObject.Factory.parse(input); } public static XmlObject createXmlObject(URL input) throws XmlException { try { return XmlObject.Factory.parse(input); } catch (Exception e) { throw new XmlException(e); } } static public void setElementText(Element elm, String text) { Node node = elm.getFirstChild(); if (node == null) { if (text != null) elm.appendChild(elm.getOwnerDocument().createTextNode(text)); } else if (node.getNodeType() == Node.TEXT_NODE) { if (text == null) node.getParentNode().removeChild(node); else node.setNodeValue(text); } else if (text != null) { Text textNode = node.getOwnerDocument().createTextNode(text); elm.insertBefore(textNode, elm.getFirstChild()); } } public static QName getQName(XmlObject contentElement) { return contentElement == null ? null : getQName(contentElement.getDomNode()); } public static QName getQName(Node node) { if (node == null) return null; else if (node.getNamespaceURI() == null) return new QName(node.getNodeName()); else return new QName(node.getNamespaceURI(), node.getLocalName()); } public static Document parseXml(String xmlString) throws IOException { return parse(new InputSource(new StringReader(xmlString))); } public static boolean setNodeValue(Node domNode, String string) { if (domNode == null) return false; short nodeType = domNode.getNodeType(); switch (nodeType) { case Node.ELEMENT_NODE: { setElementText((Element) domNode, string); break; } case Node.ATTRIBUTE_NODE: case Node.TEXT_NODE: { domNode.setNodeValue(string); break; } case Node.PROCESSING_INSTRUCTION_NODE: { ((ProcessingInstruction) domNode).setData(string); break; } case Node.CDATA_SECTION_NODE: { ((CDATASection) domNode).setData(string); break; } default: { return false; } } return true; } public static String declareXPathNamespaces(XmlObject xmlObject) { Map map = new HashMap(); XmlCursor cursor = xmlObject.newCursor(); while (cursor.hasNextToken()) { if (cursor.toNextToken().isNamespace()) map.put(cursor.getName(), cursor.getTextValue()); } cursor.dispose(); Iterator i = map.keySet().iterator(); int nsCnt = 0; StringBuffer buf = new StringBuffer(); Set prefixes = new HashSet(); Set usedPrefixes = new HashSet(); while (i.hasNext()) { QName name = i.next(); String prefix = name.getLocalPart(); if (prefix.length() == 0) prefix = "ns" + Integer.toString(++nsCnt); else if (prefix.equals("xsd") || prefix.equals("xsi")) continue; if (usedPrefixes.contains(prefix)) { int c = 1; while (usedPrefixes.contains(prefix + c)) c++; prefix = prefix + Integer.toString(c); } else prefixes.add(prefix); buf.append("declare namespace "); buf.append(prefix); buf.append("='"); buf.append(map.get(name)); buf.append("';\n"); usedPrefixes.add(prefix); } return buf.toString(); } public static String setXPathContent(String xmlText, String xpath, String value) { try { XmlObject xmlObject = XmlObject.Factory.parse(xmlText); String namespaces = declareXPathNamespaces(xmlObject); if (namespaces != null && namespaces.trim().length() > 0) xpath = namespaces + xpath; XmlObject[] path = xmlObject.selectPath(xpath); for (XmlObject xml : path) { setNodeValue(xml.getDomNode(), value); } return xmlObject.toString(); } catch (Exception e) { e.printStackTrace(); } return xmlText; } public static void serializePretty(XmlObject xmlObject, Writer writer) throws IOException { XmlOptions options = new XmlOptions(); options.setSavePrettyPrint(); options.setSavePrettyPrintIndent(3); options.setSaveNoXmlDecl(); options.setSaveAggressiveNamespaces(); // StringToStringMap map = new StringToStringMap(); // map.put( SoapVersion.Soap11.getEnvelopeNamespace(), "SOAPENV" ); // map.put( SoapVersion.Soap12.getEnvelopeNamespace(), "SOAPENV" ); // // options.setSaveSuggestedPrefixes( map ); xmlObject.save(writer, options); } } ================================================ FILE: soap-legacy/src/main/resources/license.txt ================================================ Copyright (c) ${year} ${company}. All Rights Reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ================================================ FILE: soap-legacy/src/main/resources/xsds/XMLSchema.xsd ================================================ ]> Part 1 version: Id: structures.xsd,v 1.2 2004/01/15 11:34:25 ht Exp Part 2 version: Id: datatypes.xsd,v 1.3 2004/01/23 18:11:13 ht Exp The schema corresponding to this document is normative, with respect to the syntactic constraints it expresses in the XML Schema language. The documentation (within <documentation> elements) below, is not normative, but rather highlights important aspects of the W3C Recommendation of which this is a part The simpleType element and all of its members are defined towards the end of this schema document This type is extended by almost all schema types to allow attributes from other namespaces to be added to user schemas. This type is extended by all types which allow annotation other than <schema> itself This group is for the elements which occur freely at the top level of schemas. All of their types are based on the "annotated" type by extension. This group is for the elements which can self-redefine (see <redefine> below). A utility type, not for public use A utility type, not for public use A utility type, not for public use #all or (possibly empty) subset of {extension, restriction} A utility type, not for public use A utility type, not for public use #all or (possibly empty) subset of {extension, restriction, list, union} for maxOccurs for all particles for element, group and attributeGroup, which both define and reference 'complexType' uses this This branch is short for <complexContent> <restriction base="xs:anyType"> ... </restriction> </complexContent> Will be restricted to required or forbidden Not allowed if simpleContent child is chosen. May be overriden by setting on complexContent child. This choice is added simply to make this a valid restriction per the REC Overrides any setting on complexType parent. This choice is added simply to make this a valid restriction per the REC No typeDefParticle group reference A utility type, not for public use #all or (possibly empty) subset of {substitution, extension, restriction} The element element can be used either at the top level to define an element-type binding globally, or within a content model to either reference a globally-defined element or type or declare an element-type binding locally. The ref form is not allowed at the top level. group type for explicit groups, named top-level groups and group references group type for the three kinds of group This choice with min/max is here to avoid a pblm with the Elt:All/Choice/Seq Particle derivation constraint restricted max/min Only elements allowed inside simple type for the value of the 'namespace' attr of 'any' and 'anyAttribute' Value is ##any - - any non-conflicting WFXML/attribute at all ##other - - any non-conflicting WFXML/attribute from namespace other than targetNS ##local - - any unqualified non-conflicting WFXML/attribute one or - - any non-conflicting WFXML/attribute from more URI the listed namespaces references (space separated) ##targetNamespace or ##local may appear in the above list, to refer to the targetNamespace of the enclosing schema or an absent targetNamespace respectively A utility type, not for public use A subset of XPath expressions for use in selectors A utility type, not for public use The following pattern is intended to allow XPath expressions per the following EBNF: Selector ::= Path ( '|' Path )* Path ::= ('.//')? Step ( '/' Step )* Step ::= '.' | NameTest NameTest ::= QName | '*' | NCName ':' '*' child:: is also allowed A subset of XPath expressions for use in fields A utility type, not for public use The following pattern is intended to allow XPath expressions per the same EBNF as for selector, with the following change: Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest ) The three kinds of identity constraints, all with type of or derived from 'keybase'. A utility type, not for public use A public identifier, per ISO 8879 notations for use within XML Schema schemas Not the real urType, but as close an approximation as we can get in the XML representation First the built-in primitive datatypes. These definitions are for information only, the real built-in definitions are magic. For each built-in datatype in this schema (both primitive and derived) can be uniquely addressed via a URI constructed as follows: 1) the base URI is the URI of the XML Schema namespace 2) the fragment identifier is the name of the datatype For example, to address the int datatype, the URI is: http://www.w3.org/2001/XMLSchema#int Additionally, each facet definition element can be uniquely addressed via a URI constructed as follows: 1) the base URI is the URI of the XML Schema namespace 2) the fragment identifier is the name of the facet For example, to address the maxInclusive facet, the URI is: http://www.w3.org/2001/XMLSchema#maxInclusive Additionally, each facet usage in a built-in datatype definition can be uniquely addressed via a URI constructed as follows: 1) the base URI is the URI of the XML Schema namespace 2) the fragment identifier is the name of the datatype, followed by a period (".") followed by the name of the facet For example, to address the usage of the maxInclusive facet in the definition of int, the URI is: http://www.w3.org/2001/XMLSchema#int.maxInclusive NOTATION cannot be used directly in a schema; rather a type must be derived from it by specifying at least one enumeration facet whose value is the name of a NOTATION declared in the schema. Now the derived primitive types pattern specifies the content of section 2.12 of XML 1.0e2 and RFC 3066 (Revised version of RFC 1766). pattern matches production 7 from the XML spec pattern matches production 5 from the XML spec pattern matches production 4 from the Namespaces in XML spec A utility type, not for public use #all or (possibly empty) subset of {restriction, union, list} A utility type, not for public use Can be restricted to required or forbidden Required at the top level Forbidden when nested We should use a substitution group for facets, but that's ruled out because it would allow users to add their own, which we're not ready for yet. base attribute and simpleType child are mutually exclusive, but one or other is required itemType attribute and simpleType child are mutually exclusive, but one or other is required memberTypes attribute must be non-empty or there must be at least one simpleType child ================================================ FILE: soap-legacy/src/main/resources/xsds/soapEncoding.xsd ================================================ 'root' can be used to distinguish serialization roots from other elements that are present in a serialization but are not roots of a serialized value graph Attributes common to all elements that function as accessors or represent independent (multi-ref) values. The href attribute is intended to be used in a manner like CONREF. That is, the element content should be empty iff the href attribute appears 'Array' is a complex type for accessors identified by position ================================================ FILE: soap-legacy/src/main/resources/xsds/soapEncoding12.xsd ================================================ Attributes common to all elements that function as accessors or represent independent (multi-ref) values. The ref attribute is intended to be used in a manner like CONREF. That is, the element content should be empty iff the ref attribute appears A list type that allows * and non negative integers. Used as the base type for arraySize below. Pattern based restriction of the arraySizeBase list type. Used as the type of the arraySize attribute. Restricts asterisk ( * ) to first list item only. Instances must contain at least an asterisk ( * ) or a nonNegativeInteger. May contain other nonNegativeIntegers as subsequent list items. Valid instances include; * 1 * 2 2 2 * 2 0 ================================================ FILE: soap-legacy/src/main/resources/xsds/soapEnvelope.xsd ================================================ Prose in the spec does not specify that attributes are allowed on the Body element 'encodingStyle' indicates any canonicalization conventions followed in the contents of the containing element. For example, the value 'http://schemas.xmlsoap.org/soap/encoding/' indicates the pattern described in SOAP specification Fault reporting structure ================================================ FILE: soap-legacy/src/main/resources/xsds/soapEnvelope12.xsd ================================================ Elements replacing the wildcard MUST be namespace qualified, but can be in the targetNamespace Fault reporting structure ================================================ FILE: soap-legacy/src/main/resources/xsds/swaref.xsd ================================================ ================================================ FILE: soap-legacy/src/main/resources/xsds/xmime200411.xsd ================================================ ================================================ FILE: soap-legacy/src/main/resources/xsds/xmime200505.xsd ================================================ ================================================ FILE: soap-legacy/src/main/resources/xsds/xml.xsd ================================================ See http://www.w3.org/XML/1998/namespace.html and http://www.w3.org/TR/REC-xml for information about this namespace. This schema document describes the XML namespace, in a form suitable for import by other schema documents. Note that local names in this namespace are intended to be defined only by the World Wide Web Consortium or its subgroups. The following names are currently defined in this namespace and should not be used with conflicting semantics by any Working Group, specification, or document instance: base (as an attribute name): denotes an attribute whose value provides a URI to be used as the base for interpreting any relative URIs in the scope of the element on which it appears; its value is inherited. This name is reserved by virtue of its definition in the XML Base specification. id (as an attribute name): denotes an attribute whose value should be interpreted as if declared to be of type ID. The xml:id specification is not yet a W3C Recommendation, but this attribute is included here to facilitate experimentation with the mechanisms it proposes. Note that it is _not_ included in the specialAttrs attribute group. lang (as an attribute name): denotes an attribute whose value is a language code for the natural language of the content of any element; its value is inherited. This name is reserved by virtue of its definition in the XML specification. space (as an attribute name): denotes an attribute whose value is a keyword indicating what whitespace processing discipline is intended for the content of the element; its value is inherited. This name is reserved by virtue of its definition in the XML specification. Father (in any context at all): denotes Jon Bosak, the chair of the original XML Working Group. This name is reserved by the following decision of the W3C XML Plenary and XML Coordination groups: In appreciation for his vision, leadership and dedication the W3C XML Plenary on this 10th day of February, 2000 reserves for Jon Bosak in perpetuity the XML name xml:Father This schema defines attributes and an attribute group suitable for use by schemas wishing to allow xml:base, xml:lang, xml:space or xml:id attributes on elements they define. To enable this, such a schema must import this schema for the XML namespace, e.g. as follows: <schema . . .> . . . <import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/> Subsequently, qualified reference to any of the attributes or the group defined below will have the desired effect, e.g. <type . . .> . . . <attributeGroup ref="xml:specialAttrs"/> will define a type which will schema-validate an instance element with any of those attributes In keeping with the XML Schema WG's standard versioning policy, this schema document will persist at http://www.w3.org/2005/08/xml.xsd. At the date of issue it can also be found at http://www.w3.org/2001/xml.xsd. The schema document at that URI may however change in the future, in order to remain compatible with the latest version of XML Schema itself, or with the XML namespace itself. In other words, if the XML Schema or XML namespaces change, the version of this document at http://www.w3.org/2001/xml.xsd will change accordingly; the version at http://www.w3.org/2005/08/xml.xsd will not change. Attempting to install the relevant ISO 2- and 3-letter codes as the enumerated possible values is probably never going to be a realistic possibility. See RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry at http://www.iana.org/assignments/lang-tag-apps.htm for further information. The union allows for the 'un-declaration' of xml:lang with the empty string. See http://www.w3.org/TR/xmlbase/ for information about this attribute. See http://www.w3.org/TR/xml-id/ for information about this attribute. ================================================ FILE: soap-legacy/src/main/resources/xsds/xop.xsd ================================================ ================================================ FILE: soap-server/pom.xml ================================================ 4.0.0 org.reficio soap-server bundle soap-server - XML based SOAP server org.reficio soap-ws 1.0.0-SNAPSHOT ../pom.xml org.reficio soap-builder ${project.version} org.springframework.ws spring-ws-core 2.1.1.RELEASE javax.servlet servlet-api 2.5 provided org.mortbay.jetty jetty-embedded 6.1.26 org.mortbay.jetty jetty-java5-threadpool 6.1.26 com.googlecode.guava-osgi guava-osgi commons-logging commons-logging junit junit test org.slf4j slf4j-api 1.6.6 org.slf4j slf4j-log4j12 1.6.6 org.apache.maven.plugins maven-site-plugin 3.1 true ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/OperationNotFoundException.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server; /** * Exception thrown when the invoked binding operation is not found in the WSDL * * @author Tom Bujok * @since 1.0.0 */ public class OperationNotFoundException extends SoapServerException { public OperationNotFoundException(String message) { super(message); } public OperationNotFoundException(String message, Throwable cause) { super(message, cause); } public OperationNotFoundException(Throwable cause) { super(cause); } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/ServiceRegistrationException.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server; /** * Exception thrown when an service registration error occurs (for example a double registration) * * @author Tom Bujok * @since 1.0.0 */ public class ServiceRegistrationException extends SoapServerException { public ServiceRegistrationException(String message) { super(message); } public ServiceRegistrationException(String message, Throwable cause) { super(message, cause); } public ServiceRegistrationException(Throwable cause) { super(cause); } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/SoapServerException.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server; import org.reficio.ws.SoapException; /** * Top-level exception type thrown by SoapServer * * @author Tom Bujok * @since 1.0.0 */ public class SoapServerException extends SoapException { public SoapServerException(String message) { super(message); } public SoapServerException(String message, Throwable cause) { super(message, cause); } public SoapServerException(Throwable cause) { super(cause); } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/core/SoapServer.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.core; import org.apache.log4j.Logger; import org.mortbay.jetty.AbstractConnector; import org.mortbay.jetty.Handler; import org.mortbay.jetty.Server; import org.mortbay.jetty.nio.SelectChannelConnector; import org.mortbay.jetty.security.SslSelectChannelConnector; import org.mortbay.jetty.servlet.Context; import org.reficio.ws.annotation.ThreadSafe; import org.reficio.ws.server.ServiceRegistrationException; import org.reficio.ws.server.SoapServerException; import org.reficio.ws.server.endpoint.GenericContextDomEndpoint; import org.reficio.ws.server.responder.RequestResponder; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.GenericWebApplicationContext; import javax.servlet.ServletContext; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Collections; import java.util.List; import java.util.Properties; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; /** * SOAP server enables the user to handle a SOAP communication on a purely XML level. * It supports plain HTTP as well as HTTPS communication. * When it comes to SOAP it supports SOAP 1.1 and 1.2 * This class may throw an unchecked @see org.reficio.ws.server.SoapServerException * * @author Tom Bujok * @since 1.0.0 */ @ThreadSafe public final class SoapServer { private final static Logger log = Logger.getLogger(SoapServer.class); private Integer httpPort = SoapServerConstants.HTTP_PORT; private Integer httpsPort = SoapServerConstants.HTTPS_PORT; private boolean reuseAddress = SoapServerConstants.REUSE_ADDRESS; private Integer connectionMaxIdleTimeInSeconds = SoapServerConstants.CONNECTION_MAX_IDLE_TIME_IN_SECONDS; private Integer acceptorThreads = SoapServerConstants.ACCEPTOR_THREADS_COUNT; private Integer coreThreads = SoapServerConstants.CORE_THREADS_COUNT; private Integer maxThreads = SoapServerConstants.MAX_THREADS_COUNT; private Integer threadKeepAliveTimeInSeconds = SoapServerConstants.THREAD_KEEP_ALIVE_TIME_IN_SECONDS; private URL keyStoreUrl; private String keyStoreType = SoapServerConstants.KEYSTORE_TYPE; private String keyStorePassword; // helper attributes private boolean http; private boolean https; // runtime attributes private ClassPathXmlApplicationContext context; private Server server; private GenericContextDomEndpoint endpoint; // ---------------------------------------------------------------- // PUBLIC API // ---------------------------------------------------------------- /** * Starts the SOAP server */ public void start() { try { server.start(); } catch (Exception ex) { throw new SoapServerException(ex); } } public boolean isRunning() { return server.isRunning(); } public boolean isStarted() { return server.isStarted(); } public boolean isStarting() { return server.isStarting(); } public boolean isStopping() { return server.isStopping(); } public boolean isStopped() { return server.isStopped(); } public boolean isNotRunning() { return isStopping() || isStopped(); } public boolean isFailed() { return server.isFailed(); } /** * Stops the SOAP server (does not release the allocated resources) */ public void stop() { try { server.stop(); } catch (Exception ex) { throw new SoapServerException(ex); } } /** * Stops the SOAP server and deallocates resources */ public void destroy() { stop(); context.close(); } /** * Registers responder under specified context path. Only one responder may be registered under one context path. * * @param contextPath * @param responder * @throws ServiceRegistrationException thrown if a registration error occurs - for example duplicate responder registered */ public void registerRequestResponder(String contextPath, RequestResponder responder) throws ServiceRegistrationException { checkNotNull(contextPath, "contextPath cannot be null"); checkNotNull(responder, "responder cannot be null"); validateUrl(contextPath); log.info(String.format("Registering responder [%s] under the url [%s]", responder, getUrl(contextPath))); endpoint.registerRequestResponder(contextPath, responder); } /** * Unregisters responder from the specified context path * * @param contextPath * @throws ServiceRegistrationException thrown if an unregistration error occurs - for example no responder registerd */ public void unregisterRequestResponder(String contextPath) throws ServiceRegistrationException { checkNotNull(contextPath, "contextPath cannot be null"); log.info(String.format("Unregistering responder from the url [%s]", getUrl(contextPath))); endpoint.unregisterRequestResponder(contextPath); } private String getUrl(String contextPath) { String format = String.format("%s://localhost:%d%s", http ? "http" : "https", http ? httpPort : httpsPort, contextPath); return format; } private void validateUrl(String contextPath) { checkArgument(contextPath.startsWith("/"), "contextPath has to begin with a slash"); String url = getUrl(contextPath); try { new URI(url); } catch (URISyntaxException e) { throw new IllegalArgumentException(String.format("URL with context path is malformed [%s]", url), e); } } /** * @return a list of registered context paths */ public List getRegisteredContextPaths() { return Collections.list(endpoint.getRegisteredContextPaths()); } // ---------------------------------------------------------------- // INTERNAL API // ---------------------------------------------------------------- private void configure() { configureParentContext(); configureConnectors(); configureWebContext(); } private void configureParentContext() { PropertyPlaceholderConfigurer config = new PropertyPlaceholderConfigurer(); config.setProperties(buildProperties()); context = new ClassPathXmlApplicationContext(); context.addBeanFactoryPostProcessor(config); context.setConfigLocation(SoapServerConstants.SPRING_CONTEXT_LOCATION); context.refresh(); context.registerShutdownHook(); server = context.getBean(SoapServerConstants.SERVER_BEAN_NAME, Server.class); } private void configureConnectors() { if (http) { SelectChannelConnector httpConnector = context.getBean(SoapServerConstants.CONNECTOR_BEAN_NAME, SelectChannelConnector.class); configureHttpConnector(httpConnector); server.addConnector(httpConnector); } if (https) { checkNotNull(keyStoreUrl, "keyStore has to be set in https mode"); SslSelectChannelConnector httpsConnector = context.getBean(SoapServerConstants.SSL_CONNECTOR_BEAN_NAME, SslSelectChannelConnector.class); configureHttpsConnector(httpsConnector); server.addConnector(httpsConnector); } } private SelectChannelConnector configureHttpConnector(SelectChannelConnector connector) { configureGenericConnector(connector); connector.setReuseAddress(reuseAddress); connector.setPort(httpPort); return connector; } private SslSelectChannelConnector configureHttpsConnector(SslSelectChannelConnector connector) { configureGenericConnector(connector); connector.setReuseAddress(reuseAddress); connector.setPort(httpsPort); connector.setKeystore(keyStoreUrl.toString()); connector.setKeystoreType(keyStoreType); connector.setKeyPassword(keyStorePassword); return connector; } private AbstractConnector configureGenericConnector(AbstractConnector connector) { connector.setAcceptors(acceptorThreads); connector.setMaxIdleTime(connectionMaxIdleTimeInSeconds * SoapServerConstants.SECONDS_TO_MILLIS_RATIO); return connector; } private void configureWebContext() { ServletContext servletContext = getServletContext(); GenericWebApplicationContext webContext = new GenericWebApplicationContext(); webContext.setServletContext(servletContext); webContext.setParent(context); webContext.refresh(); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webContext); if (webContext != null) { endpoint = webContext.getBean(SoapServerConstants.ENDPOINT_BEAN_NAME, GenericContextDomEndpoint.class); } } private ServletContext getServletContext() { for (Handler handler : server.getHandlers()) { if (handler instanceof Context) { return ((Context) handler).getServletContext(); } } return null; } private Properties buildProperties() { Properties properties = new Properties(); properties.setProperty(SoapServerConstants.CORE_POOL_SIZE_PROP_KEY, coreThreads.toString()); properties.setProperty(SoapServerConstants.MAX_POOL_SIZE_PROP_KEY, maxThreads.toString()); properties.setProperty(SoapServerConstants.KEEP_ALIVE_PROP_KEY, threadKeepAliveTimeInSeconds.toString()); return properties; } // ---------------------------------------------------------------- // BUILDER API // ---------------------------------------------------------------- private SoapServer() { } /** * Builder to construct a properly populated SoapServer */ public static class Builder { private final SoapServer server = new SoapServer(); /** * @param value Sets the http port on which the server listens. Has to be not negative. * @return builder */ public Builder httpPort(int value) { checkArgument(value >= 0); server.http = true; server.httpPort = value; return this; } /** * @param value Sets the https port on which the server listens. Has to be not negative. * @return builder */ public Builder httpsPort(int value) { checkArgument(value >= 0); server.https = true; server.httpsPort = value; return this; } /** * @param value Sets the connection max idle time in seconds. Has to be not negative. * @return builder */ public Builder connectionMaxIdleTimeInSeconds(int value) { checkArgument(value >= 0); server.connectionMaxIdleTimeInSeconds = value; return this; } /** * @param value Sets the number of http server connector acceptor threads. Has to be positive. * @return builder */ public Builder acceptorThreads(int value) { checkArgument(value > 0); server.acceptorThreads = value; return this; } /** * @param value Sets the number of http server core threads. Has to be positive. * @return builder */ public Builder coreThreads(int value) { checkArgument(value > 0); server.coreThreads = value; return this; } /** * @param value Sets the maximal number of threads that the http server may spawn. Has to be positive. * @return builder */ public Builder maxThreads(int value) { checkArgument(value > 0); server.maxThreads = value; return this; } /** * @param value Sets the value of thread keep alive in seconds. Has to be not negative. * @return builder */ public Builder threadKeepAliveTimeInSeconds(int value) { checkArgument(value >= 0); server.threadKeepAliveTimeInSeconds = value; return this; } /** * @param value Specifies the URL of the keystore to use in the SOAP communication. Null is not accepted. If there's more than * one certificate in the keystore it is undefined which of them will be used * @return builder */ public Builder keyStoreUrl(URL value) { checkNotNull(value); server.keyStoreUrl = value; return this; } /** * @param value Specifies the type of the keystore. Null is not accepted. * @return builder */ public Builder keyStoreType(String value) { checkNotNull(value); server.keyStoreType = value; return this; } /** * @param value keystore password. Null is accepted. * @return builder */ public Builder keyStorePassword(String value) { server.keyStorePassword = value; return this; } /** * @param value Sets the reuseAddress on the underlying @see java.net.Socket * @return builder */ public Builder reuseAddress(boolean value) { server.reuseAddress = value; return this; } /** * Builds populated SoapServer instance * * @return builder */ public SoapServer build() { server.configure(); return server; } } /** * @return a new instance of a SoapServer Builder */ public static Builder builder() { return new Builder(); } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/core/SoapServerConstants.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.core; /** * @author Tom Bujok * @since 1.0.0 */ final class SoapServerConstants { private SoapServerConstants() { } public static final int HTTP_PORT = 8080; public static final int HTTPS_PORT = 8443; public static final int CONNECTION_MAX_IDLE_TIME_IN_SECONDS = 60; public static final int ACCEPTOR_THREADS_COUNT = 4; public static final int CORE_THREADS_COUNT = 8; public static final int MAX_THREADS_COUNT = 16; public static final int THREAD_KEEP_ALIVE_TIME_IN_SECONDS = 60; public static final String KEYSTORE_TYPE = "JKS"; public static final boolean REUSE_ADDRESS = true; public static final String SPRING_CONTEXT_LOCATION = "classpath:soap-server.xml"; public static final String SERVER_BEAN_NAME = "jettyServer"; public static final String CONNECTOR_BEAN_NAME = "connector"; public static final String SSL_CONNECTOR_BEAN_NAME = "sslConnector"; public static final String ENDPOINT_BEAN_NAME = "endpoint"; public static final String CORE_POOL_SIZE_PROP_KEY = "core.pool.size"; public static final String MAX_POOL_SIZE_PROP_KEY = "max.pool.size"; public static final String KEEP_ALIVE_PROP_KEY = "keep.alive.time"; public static final int SECONDS_TO_MILLIS_RATIO = 1000; } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/core/SoapServerFactory.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.core; import org.reficio.ws.server.responder.RequestResponder; import java.net.URL; import java.util.HashMap; import java.util.Map; import static com.google.common.base.Preconditions.checkNotNull; /** * @author Tom Bujok * @since 1.0.0 */ public class SoapServerFactory { private Integer httpPort; private Integer httpsPort; private Boolean reuseAddress; private Integer connectionMaxIdleTimeInSeconds; private Integer acceptorThreads; private Integer coreThreads; private Integer maxThreads; private Integer threadKeepAliveTimeInSeconds; private URL keyStoreUrl; private String keyStoreType; private String keyStorePassword; private Map responders; public void setHttpPort(Integer value) { checkNotNull(value); this.httpPort = value; } public void setHttpsPort(Integer value) { checkNotNull(value); this.httpsPort = value; } public void setConnectionMaxIdleTimeInSeconds(Integer value) { checkNotNull(value); this.connectionMaxIdleTimeInSeconds = value; } public void setAcceptorThreads(Integer value) { checkNotNull(value); this.acceptorThreads = value; } public void setCoreThreads(Integer value) { checkNotNull(value); this.coreThreads = value; } public void setMaxThreads(Integer value) { checkNotNull(value); this.maxThreads = value; } public void setThreadKeepAliveTimeInSeconds(Integer value) { checkNotNull(value); this.threadKeepAliveTimeInSeconds = value; } public void setKeyStoreUrl(URL value) { checkNotNull(value); this.keyStoreUrl = value; } public void setKeyStoreType(String value) { checkNotNull(value); this.keyStoreType = value; } public void setKeyStorePassword(String value) { this.keyStorePassword = value; } public void setReuseAddress(Boolean value) { checkNotNull(value); this.reuseAddress = value; } public void setResponders(Map responders) { checkNotNull(responders); this.responders = new HashMap(responders); } public SoapServer create() { SoapServer.Builder builder = SoapServer.builder(); configureConnection(builder); configureThreadPools(builder); configureTimeouts(builder); configureKeyStore(builder); SoapServer server = builder.build(); configureResponders(server); return server; } private void configureResponders(SoapServer server) { for(Map.Entry entry : responders.entrySet()) { server.registerRequestResponder(entry.getKey(), entry.getValue()); } } private void configureThreadPools(SoapServer.Builder builder) { if (acceptorThreads != null) { builder.acceptorThreads(acceptorThreads); } if (coreThreads != null) { builder.coreThreads(coreThreads); } if (maxThreads != null) { builder.maxThreads(maxThreads); } } private void configureTimeouts(SoapServer.Builder builder) { if (connectionMaxIdleTimeInSeconds != null) { builder.connectionMaxIdleTimeInSeconds(connectionMaxIdleTimeInSeconds); } if (threadKeepAliveTimeInSeconds != null) { builder.threadKeepAliveTimeInSeconds(threadKeepAliveTimeInSeconds); } } private void configureConnection(SoapServer.Builder builder) { if (httpPort != null) { builder.httpPort(httpPort); } if (httpsPort != null) { builder.httpsPort(httpsPort); } if (reuseAddress != null) { builder.reuseAddress(reuseAddress); } } private void configureKeyStore(SoapServer.Builder builder) { if (keyStoreUrl != null) { builder.keyStoreUrl(keyStoreUrl); } if (keyStoreType != null) { builder.keyStoreType(keyStoreType); } builder.keyStorePassword(keyStorePassword); } public static void main(String[] args) { SoapServerFactory f = new SoapServerFactory(); f.setHttpPort(9999); SoapServer s = f.create(); s.start(); } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/endpoint/ContextEndpointAdapter.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.endpoint; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.adapter.PayloadEndpointAdapter; import javax.xml.transform.Source; /** * It is an extension of the @see org.springframework.ws.server.endpoint.adapter.PayloadEndpointAdapter. * It is implemented in such a way that expects the ContextPayloadEndpoint which expects the context of the message in the * invoke method. This adapter provides this message context to the endpoint. It also sets the reply in the context by populating * the GenericSoapMessage - which contains the whole SOAP message (envelope = header + body). * * @author Tom Bujok * @since 1.0.0 */ public class ContextEndpointAdapter extends PayloadEndpointAdapter { @Override public void invoke(MessageContext messageContext, Object endpoint) { ContextPayloadEndpoint payloadEndpoint = (ContextPayloadEndpoint) endpoint; Source responseSource = payloadEndpoint.invoke(messageContext); GenericSoapMessage message = new GenericSoapMessage(responseSource); messageContext.setResponse(message); } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/endpoint/ContextPayloadEndpoint.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.endpoint; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.PayloadEndpoint; import javax.xml.transform.Source; /** * @author Tom Bujok * @since 1.0.0 */ public interface ContextPayloadEndpoint extends PayloadEndpoint { /** * Invokes the endpoint with the given request and possibly returns a response. * It extends the functionality of a @see org.springframework.ws.server.endpoint.PayloadEnpoint * by decorating the invocation of the invoke method -> it get the context of the message as an argument * enabling the user to control the invocation in a more detailed way. * * @param messageContext the context of the message containing the request and (possible response) * @return the payload of the response message, may be null to indicate no response * @throws Exception if an exception occurs */ Source invoke(MessageContext messageContext); } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/endpoint/GenericContextDomEndpoint.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.endpoint; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.reficio.ws.server.ServiceRegistrationException; import org.reficio.ws.server.SoapServerException; import org.reficio.ws.server.responder.RequestResponder; import org.springframework.beans.factory.InitializingBean; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import javax.servlet.http.HttpServletRequest; import javax.xml.transform.Source; import java.util.Enumeration; import java.util.concurrent.ConcurrentHashMap; /** * Implementation of the ContextPayloadEndpoint and AbstractDomPayloadEndpoint. It handles all SOAP requests. * It checks the context path of the request and then gets the responder registered under that context path. * If an responder exists it is invoked passing the message context to it, if it does not exist an exception * is thrown. * It also contains the API to register, unregister responders and get all responders registered in this endpoint. * * @author Tom Bujok * @since 1.0.0 */ public class GenericContextDomEndpoint implements ContextPayloadEndpoint, InitializingBean { private final static Log log = LogFactory.getLog(GenericContextDomEndpoint.class); /** * Map containing all registered context paths and request responders */ private final ConcurrentHashMap services; public GenericContextDomEndpoint() { this.services = new ConcurrentHashMap(); } /** * Implementation of the invoke message that gets the MessageContext. It enables the responders to the the whole * SOAP envelope (and not only the request element); * The responders are invoked with that context. If there's no responder an exception is thrown. */ @Override public Source invoke(MessageContext messageContext) { RequestResponder requestResponder = getRequestResponderBySessionRequestContextPath(); if (noResponderForRequestFound(requestResponder)) { handleNoResponderFault(); } SoapMessage msg = (SoapMessage) messageContext.getRequest(); Source response = requestResponder.respond(msg); return response; } private RequestResponder getRequestResponderBySessionRequestContextPath() { HttpServletRequest htpServletRequest = getHttpServletRequest(); return getRequestResponderByRequestContextPath(htpServletRequest.getRequestURI()); } private RequestResponder getRequestResponderByRequestContextPath(String contextPath) { return services.get(contextPath); } private boolean noResponderForRequestFound(RequestResponder responder) { if (responder == null) { return true; } return false; } private Source handleNoResponderFault() { String msg = String.format("There is no service under the requested context path [%s]", getRequestContextPath()); throw new SoapServerException(msg); } private HttpServletRequest getHttpServletRequest() { return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); } private String getRequestContextPath() { return getHttpServletRequest().getRequestURI(); } /** * Enables to register a responder under the specified context path * * @param contextPath to be used by the responder * @param responder request responder * @throws ServiceRegistrationException thrown if error occurs, for example path is already taken */ public void registerRequestResponder(String contextPath, RequestResponder responder) throws ServiceRegistrationException { if (services.putIfAbsent(contextPath, responder) != null) { throw new ServiceRegistrationException(String.format("Specified context path [%s] is already taken", contextPath)); } } /** * Unregisters the responder from the specified context path * * @param contextPath context path from which the responder should be removed * @throws ServiceRegistrationException thrown if error occurs, for example no service under the specified path */ public void unregisterRequestResponder(String contextPath) throws ServiceRegistrationException { if (services.remove(contextPath) == null) { throw new ServiceRegistrationException(String.format("There was no service under the specified context path [%s]", contextPath)); } } /** * @return Returns an enumeration of the taken context paths */ public Enumeration getRegisteredContextPaths() { return services.keys(); } @Override public void afterPropertiesSet() { log.info("Generic SOAP endpoint initialized"); } /** * Empty method included here to be compliant with the PayloadEndpoint. * Not used here as it does not enable the user to get the whole SOAP envelope. */ @Override public Source invoke(Source request) throws Exception { throw new SoapServerException("This method is not implemented - it SHOULD NOT be used."); } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/endpoint/GenericEndpointMapping.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.endpoint; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.endpoint.mapping.AbstractEndpointMapping; /** * Endpoint mapping that always invokes the generic endpoint * * @author Tom Bujok * @since 1.0.0 */ public class GenericEndpointMapping extends AbstractEndpointMapping { /** * Generic endpoint that handles all invocations */ private ContextPayloadEndpoint genericEndpoint; @Override protected Object getEndpointInternal(MessageContext messageContext) { return genericEndpoint; } public ContextPayloadEndpoint getGenericEndpoint() { return genericEndpoint; } public void setGenericEndpoint(ContextPayloadEndpoint genericEndpoint) { this.genericEndpoint = genericEndpoint; } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/endpoint/GenericSoapMessage.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.endpoint; import org.reficio.ws.common.XmlUtils; import org.reficio.ws.server.SoapServerException; import org.springframework.ws.WebServiceMessage; import javax.xml.transform.Result; import javax.xml.transform.Source; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.Charset; /** * Implementation of a generic WebServiceMessage that contains the whole envelope in the source (envelope = header + body). * * @author Tom Bujok * @since 1.0.0 */ public class GenericSoapMessage implements WebServiceMessage { /** * Source containing the whole SOAP envelope (envelope = header + body). */ private final Source source; public GenericSoapMessage(Source source) { this.source = source; } @Override public Source getPayloadSource() { return source; } @Override public Result getPayloadResult() { throw new SoapServerException("This method is not implemented - it SHOULD NOT be used."); } @Override public void writeTo(OutputStream outputStream) throws IOException { Writer writer = new OutputStreamWriter(outputStream, Charset.forName("UTF-8")); String message = XmlUtils.sourceToXmlString(source); writer.write(message); writer.flush(); writer.close(); } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/matcher/AggregatingVisitor.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.matcher; import java.util.HashSet; import java.util.Set; /** * Abstract visitor that contains convenience methods to store and retrieve results of a generic-type * * @author Tom Bujok * @since 1.0.0 */ public abstract class AggregatingVisitor implements BindingOperationVisitor { private Set results = new HashSet(); /** * Stores a result * @param result result to store */ public void addResult(T result) { results.add(result); } /** * Returns a result if only one was found * @return found unique result */ public T getUniqueResult() { // return if only one unique result was found if(results.size() == 1) { return results.iterator().next(); } return null; } /** * Returns all found results * @return Returns all found results */ public Set getResults() { return new HashSet(results); } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/matcher/BindingOperationVisitor.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.matcher; import javax.wsdl.BindingOperation; /** * Visitor of a BindingOperation * * @author Tom Bujok * @since 1.0.0 */ public interface BindingOperationVisitor { /** * Visits a BindingOperation * @param operation operation to visit */ void visit(BindingOperation operation); } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/matcher/SoapOperationMatcher.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.matcher; import org.apache.commons.lang3.StringUtils; import org.reficio.ws.builder.core.SoapUtils; import org.reficio.ws.common.XmlUtils; import org.reficio.ws.legacy.SoapLegacyFacade; import org.reficio.ws.server.OperationNotFoundException; import org.springframework.ws.soap.SoapMessage; import org.w3c.dom.Node; import javax.wsdl.Binding; import javax.wsdl.BindingOperation; import javax.wsdl.OperationType; import javax.wsdl.Part; import javax.xml.namespace.QName; import javax.xml.transform.dom.DOMSource; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; /** * Matches SOAP message to the binding operation. * Tries to match a SOAP message to a binding operation using the following mechanisms: * - SOAP Action mapping * - RCP bindings are matched using single top-level tag with the name of the invoked operation * - Document bindings are matched by input types and then by input names *

* Thanks to Spring SOAPAction in both SOAP versions is treated transparently. *

* Resources about SOAP-Action mystery in SOAP 1.1: * http://ws-rx.blogspot.com/2006/01/web-services-design-tips-soapaction.html * http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528 * http://www.oreillynet.com/xml/blog/2002/11/unraveling_the_mystery_of_soap.html * http://damithakumarage.wordpress.com/2008/02/12/soap-action-and-addressing-action/ * * @author Tom Bujok * @since 1.0.0 */ public class SoapOperationMatcher { protected final Binding binding; protected final boolean rpc; public SoapOperationMatcher(Binding binding) { this.binding = binding; this.rpc = SoapLegacyFacade.isRpc(binding); } /** * @return returns true if the binding is an RPC binding */ protected boolean isRpc() { return rpc; } /** * @return returns true if the binding is an Document binding */ protected boolean isDocument() { return isRpc() == false; } /** * Matches the SoapMessage to an binding operation *

* Tries to match using the following mechanisms: * - SOAP Action mapping * - RCP bindings are matched using single top-level tag with the name of the invoked operation * - Document bindings are matched by input types and then by input names *

* * @param message message passed by the SOAP client * @return the BindingOperation matched to the message * @throws org.reficio.ws.server.OperationNotFoundException * if operation not found in the binding */ public BindingOperation getInvokedOperation(SoapMessage message) throws OperationNotFoundException { // SOAP action mapping - cheapest and fastest as no request analysis is required BindingOperation invokedOperation = getOperationBySoapAction(message); if (invokedOperation != null) { return invokedOperation; } Set rootNodes = XmlUtils.getRootNodes((DOMSource) message.getPayloadSource()); if (isRpc()) { // rpc-type requests always contain single top-level tag with invoked operation invokedOperation = getOperationByRootQName(rootNodes); if (invokedOperation != null) { return invokedOperation; } } else { // match by types of input arguments - if two operation defined with the same argument types // unable to distinguish invokedOperation = getOperationByInputTypes(rootNodes); if (invokedOperation != null) { return invokedOperation; } // malformed services - rare but possible - if two operation defined with the same argument names // unable to distinguish invokedOperation = getOperationByInputNames(rootNodes); if (invokedOperation != null) { return invokedOperation; } } throw new OperationNotFoundException("Cannot match a SOAP operation to the given SOAP request"); } private BindingOperation getOperationBySoapAction(SoapMessage message) { final String soapActionToMatch = SoapUtils.normalizeSoapAction(message.getSoapAction()); // optimization - if no soap action skip the visitor if (StringUtils.isBlank(soapActionToMatch)) { return null; } AggregatingVisitor visitor = new AggregatingVisitor() { @Override public void visit(BindingOperation operation) { String soapAction = SoapUtils.normalizeSoapAction(SoapUtils.getSOAPActionUri(operation)); if (soapAction.equals(soapActionToMatch)) { addResult(operation); } } }; visitOperation(visitor); return visitor.getUniqueResult(); } private BindingOperation getOperationByRootQName(Set rootNodes) throws OperationNotFoundException { // check if only one root node exists if (rootNodes.isEmpty() || rootNodes.size() > 1) { throw new OperationNotFoundException("No unique top-level node containing the operation name in the rpc request."); } QName root = XmlUtils.nodeToQName(rootNodes.iterator().next()); return matchElementNameToOperationName(root); } /** * rpc-style -> operation name is always encoded in the request */ private BindingOperation matchElementNameToOperationName(final QName elementName) { AggregatingVisitor visitor = new AggregatingVisitor() { @Override public void visit(BindingOperation operation) { if (operation.getOperation().getName().equals(elementName.getLocalPart())) { addResult(operation); } } }; visitOperation(visitor); return visitor.getUniqueResult(); } /** * Last matching mechanism -> * When a non ws-compliant document-literal service specifies wsdl:part using the type instead of the element tag * Resources: * http://stackoverflow.com/questions/1172118/what-is-the-difference-between-type-and-element-in-wsdl * http://www.xfront.com/ElementVersusType.html * http://www.xfront.com/GlobalVersusLocal.html !!! * * @param rootNodes root nodes of the request * @return operation matched */ @SuppressWarnings("unchecked") private BindingOperation getOperationByInputTypes(final Set rootNodes) { AggregatingVisitor visitor = new AggregatingVisitor() { @Override public void visit(BindingOperation operation) { Collection expectedParts = operation.getOperation().getInput().getMessage().getParts().values(); Set expectedTypes = new HashSet(); for (Part part : expectedParts) { expectedTypes.add(part.getElementName()); } Set receivedTypes = XmlUtils.getNodeTypes(rootNodes); if (expectedTypes.equals(receivedTypes)) { addResult(operation); } else if (expectedParts.isEmpty() && receivedTypes.size() == 1) { // check the case when pseudo input name was sent when no input was expected and got one element QName receivedType = receivedTypes.toArray(new QName[receivedTypes.size()])[0]; String namespaceUri = operation.getOperation().getInput().getMessage().getQName().getNamespaceURI(); String name = operation.getOperation().getName(); QName pseudoInputName = new QName(namespaceUri, name); if (pseudoInputName.equals(receivedType)) { addResult(operation); } } } }; visitOperation(visitor); return visitor.getUniqueResult(); } /** * document style service -> there is not encoded operation name - matching based on the input style * * @param rootNodes root nodes of the request * @return operation matched */ @SuppressWarnings("unchecked") private BindingOperation getOperationByInputNames(final Set rootNodes) { AggregatingVisitor visitor = new AggregatingVisitor() { @Override public void visit(BindingOperation operation) { Set expectedNames = operation.getOperation().getInput().getMessage().getParts().keySet(); Set receivedNames = XmlUtils.getNodeNames(rootNodes); if (receivedNames.equals(expectedNames)) { addResult(operation); } } }; visitOperation(visitor); return visitor.getUniqueResult(); } @SuppressWarnings("unchecked") private T visitOperation(T visitor) { for (BindingOperation operation : (List) binding.getBindingOperations()) { try { visitor.visit(operation); } catch (NullPointerException ex) { // double-check in case of malformed WSDL's } } return visitor; } public boolean isRequestResponseOperation(BindingOperation operation) { // return operation.getBindingOutput() != null && operation.getBindingOutput().getName() != null; return operation.getOperation().getStyle().equals(OperationType.REQUEST_RESPONSE); } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/protocol/GenericSoapMessageFactory.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.protocol; import org.springframework.beans.factory.InitializingBean; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.SoapMessageFactory; import org.springframework.ws.soap.SoapVersion; import org.springframework.ws.soap.saaj.SaajSoapMessageFactory; import org.springframework.ws.transport.TransportInputStream; import java.io.IOException; import java.io.InputStream; /** * SOAP message factory that enables the exposition of a SOAP endpoint using both SOAP 1.1 and SOAP 1.2 versions. * It uses the SoapProtocolChooser to check which version of SOAP is used. * * @author Tom Bujok * @since 1.0.0 */ public class GenericSoapMessageFactory implements SoapMessageFactory, InitializingBean { private static final String REQUEST_CONTEXT_ATTRIBUTE = "GenericSoapMessageFactory"; /** * Factory for SOAP 1.1 messages */ private final SaajSoapMessageFactory soap11; /** * Factory for SOAP 1.2 messages */ private final SaajSoapMessageFactory soap12; /** * Chooses the version of SOAP protocol */ private SoapProtocolChooser soapProtocolChooser; public GenericSoapMessageFactory() { this.soap11 = new SaajSoapMessageFactory(); this.soap12 = new SaajSoapMessageFactory(); this.soapProtocolChooser = new SimpleSoapProtocolChooser(); } private void setMessageFactoryForRequestContext(SaajSoapMessageFactory factory) { RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); attributes.setAttribute(REQUEST_CONTEXT_ATTRIBUTE, factory, RequestAttributes.SCOPE_REQUEST); } private SaajSoapMessageFactory getMessageFactoryForRequestContext() { RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); return (SaajSoapMessageFactory) attributes.getAttribute(REQUEST_CONTEXT_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST); } public void setSoapVersion(SoapVersion version) { // ignore this, it will be set automatically } public void setSoapProtocolChooser(SoapProtocolChooser soapProtocolChooser) { this.soapProtocolChooser = soapProtocolChooser; } private void configureFactory(SaajSoapMessageFactory factory, SoapVersion version) { factory.setSoapVersion(version); factory.afterPropertiesSet(); } @Override public void afterPropertiesSet() { configureFactory(soap11, SoapVersion.SOAP_11); configureFactory(soap12, SoapVersion.SOAP_12); } @Override public SoapMessage createWebServiceMessage() { return getMessageFactoryForRequestContext().createWebServiceMessage(); } @Override public SoapMessage createWebServiceMessage(InputStream inputStream) throws IOException { setMessageFactoryForRequestContext(soap11); if (inputStream instanceof TransportInputStream) { TransportInputStream transportInputStream = (TransportInputStream) inputStream; if (soapProtocolChooser.useSoap12(transportInputStream)) { setMessageFactoryForRequestContext(soap12); } } SaajSoapMessageFactory mf = getMessageFactoryForRequestContext(); return mf.createWebServiceMessage(inputStream); } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/protocol/SimpleSoapProtocolChooser.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.protocol; import org.springframework.ws.transport.TransportInputStream; import java.io.IOException; import java.util.Iterator; /** * Chooses which soap version is used in the transmission. * It is a simple implementation that verifies the the content-type header. * * @author Tom Bujok * @since 1.0.0 */ public class SimpleSoapProtocolChooser implements SoapProtocolChooser { private static final String CONTENT_TYPE_HEADER_NAME = "content-type"; private static final String CONTENT_TYPE_HEADER_CONTENT_SOAP_11 = "text/xml"; /** * @param transportInputStream input stream from the SOAP client * @return true if SOAP 1.1 is used * @throws IOException in case an error occurs */ @Override public boolean useSoap11(TransportInputStream transportInputStream) throws IOException { for (Iterator headerNames = transportInputStream.getHeaderNames(); headerNames.hasNext(); ) { String headerName = (String) headerNames.next(); for (Iterator headerValues = transportInputStream.getHeaders(headerName); headerValues.hasNext(); ) { String headerValue = (String) headerValues.next(); if (headerName.toLowerCase().contains(CONTENT_TYPE_HEADER_NAME)) { if (headerValue.trim().toLowerCase().contains(CONTENT_TYPE_HEADER_CONTENT_SOAP_11)) { return true; } } } } return false; } /** * @param transportInputStream input stream from the SOAP client * @return true if SOAP 1.2 is used * @throws IOException in case an error occurs */ @Override public boolean useSoap12(TransportInputStream transportInputStream) throws IOException { return useSoap11(transportInputStream) == false; } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/protocol/SoapProtocolChooser.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.protocol; import org.springframework.ws.transport.TransportInputStream; import java.io.IOException; /** * Describes the functionality of SOAP version verification * * @author Tom Bujok * @since 1.0.0 */ public interface SoapProtocolChooser { boolean useSoap11(TransportInputStream transportInputStream) throws IOException; boolean useSoap12(TransportInputStream transportInputStream) throws IOException; } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/responder/AbstractResponder.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.responder; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.SoapOperation; import org.reficio.ws.builder.core.SoapUtils; import org.reficio.ws.server.OperationNotFoundException; import org.reficio.ws.server.SoapServerException; import org.reficio.ws.server.matcher.SoapOperationMatcher; import org.springframework.ws.soap.SoapMessage; import javax.wsdl.Binding; import javax.wsdl.BindingOperation; import javax.xml.transform.Source; /** * Convenience class that implements the RequestResponder interface and * contains a mechanism that matches the request to an operation from the Binding * RequestResponder method is implemented, but a new abstract respond method is added * which contains the invoked operation as an argument. * * @author Tom Bujok * @since 1.0.0 */ public abstract class AbstractResponder implements RequestResponder { private final SoapBuilder builder; private final Binding binding; private final SoapOperationMatcher soapOperationMatcher; public SoapBuilder getBuilder() { return builder; } /** * Constructs a responder for the specified binding of the builder * * @param builder Soap builder used to construct messages */ public AbstractResponder(SoapBuilder builder) { this.builder = builder; this.binding = builder.getBinding(); this.soapOperationMatcher = new SoapOperationMatcher(builder.getBinding()); } /** * Implementation of the RequestResponder bare method. * It matches the SoapMessage to the binding operation and invokes the * abstract respond method that contains OperationWrapper as an argument. * * @param message SOAP message passed by the client * @return response in the XML source format containing the whole SOAP envelope */ @Override public Source respond(SoapMessage message) { try { BindingOperation invokedOperation = soapOperationMatcher.getInvokedOperation(message); if (soapOperationMatcher.isRequestResponseOperation(invokedOperation)) { SoapOperation operation = SoapUtils.createOperation(builder, binding, invokedOperation, message.getSoapAction()); return respond(operation, message); } return null; } catch (OperationNotFoundException e) { throw new SoapServerException(e); } } /** * Abstract method that should be implemented by overriding classes. * This method is invoked whenever a request is send by the client. * InvokedOperation may be passed to a SoapBuilder to construct the * response to the request that was sent by the client. * * @param invokedOperation operation from the binding that is matched to the SOAP message * @param message SOAP message passed by the client * @return response in the XML source format containing the whole SOAP envelope */ public abstract Source respond(SoapOperation invokedOperation, SoapMessage message); } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/responder/AutoResponder.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.responder; import org.reficio.ws.SoapContext; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.SoapOperation; import org.reficio.ws.common.XmlUtils; import org.reficio.ws.server.SoapServerException; import org.springframework.ws.soap.SoapMessage; import javax.xml.transform.Source; /** * Convenience class to create SOAP mock services. * It replies with an sample response to all requests send to this responder. * SoapContext passed in the constructor may be used to fine-tune the generation * of the sample responses. * * @author Tom Bujok * @since 1.0.0 */ public class AutoResponder extends AbstractResponder { private final SoapContext context; /** * Constructs an auto responder for the specified binding of the builder * * @param builder Soap builder used to construct messages */ public AutoResponder(SoapBuilder builder) { super(builder); this.context = SoapContext.builder().exampleContent(true).build(); } /** * Constructs an auto responder for the specified binding of the builder, fine-tuning the content of the generated messages * by passing the SoapContext * * @param builder Soap builder used to construct messages * @param context Contect that is passed to the builder to fine-tune the content of the generated responses */ public AutoResponder(SoapBuilder builder, SoapContext context) { super(builder); this.context = context; } @Override public Source respond(SoapOperation invokedOperation, SoapMessage message) { try { String response = getBuilder().buildOutputMessage(invokedOperation, context); return XmlUtils.xmlStringToSource(response); } catch (Exception e) { throw new SoapServerException(e); } } } ================================================ FILE: soap-server/src/main/java/org/reficio/ws/server/responder/RequestResponder.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server.responder; import org.springframework.ws.soap.SoapMessage; import javax.xml.transform.Source; /** * Interface describing the functionality of a SOAP Request Responder * * @author Tom Bujok * @since 1.0.0 */ public interface RequestResponder { /** * Returns a response to a SOAP message.
*

* How to get full SOAP message envelope (envelope = header + body): * msg.getEnvelope().getSource() *

* How to get header section: * msg.getEnvelope().getHeader().getSource() *

* How to get body section: * msg.getEnvelope().getBody().getSource() *

* How to convert XML String to XML Source: * XmlUtils.xmlStringToSource(string); *

* How to convert XML Source to XML String: * XmlUtils.sourceToXmlString(source); * * @param request SOAP message to handle * @return response in the XML source format containing the whole SOAP envelope */ Source respond(SoapMessage request); } ================================================ FILE: soap-server/src/main/resources/soap-server.xml ================================================ ================================================ FILE: soap-server/src/main/resources/soap-servlet.xml ================================================ ================================================ FILE: soap-server/src/test/java/org/reficio/ws/server/PasswordLessKeystoreTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server; /** * Copyright (c) 2012 centeractive ag. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.junit.Ignore; import org.junit.Test; import org.reficio.ws.common.ResourceUtils; import org.reficio.ws.server.core.SoapServer; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.net.URL; import java.security.Key; import java.security.KeyStore; import java.security.cert.Certificate; import static org.junit.Assert.assertNotNull; /** * @author Tom Bujok * @since 1.0.0 */ @Ignore // not supported yet public class PasswordLessKeystoreTest { // helper method public void generateKeyLessKeystore() throws Exception { URL keyStoreUrl = ResourceUtils.getResourceWithAbsolutePackagePath("/keystores", ".keystore"); InputStream in = keyStoreUrl.openStream(); KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); ks.load(in, "changeit".toCharArray()); in.close(); String path = keyStoreUrl.getFile().replace(".keystore", "keyless2.keystore"); File file = new File(path); FileOutputStream out = new FileOutputStream(file); Certificate certificate = ks.getCertificate("john"); assertNotNull(certificate); Key key = ks.getKey("john", "changeit".toCharArray()); assertNotNull(key); KeyStore keyLess = KeyStore.getInstance(KeyStore.getDefaultType()); keyLess.load(null); keyLess.setKeyEntry("tom", key, "".toCharArray(), new Certificate[] {certificate}); keyLess.store(out, "".toCharArray()); } @Test public void trustStoreUrl() throws Exception { URL keyStoreUrl = ResourceUtils.getResourceWithAbsolutePackagePath("/keystores", "keyless.keystore"); InputStream in = keyStoreUrl.openStream(); KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); ks.load(in, null); in.close(); Certificate certificate = ks.getCertificate("tom"); assertNotNull(certificate); Key key = ks.getKey("tom", "".toCharArray()); assertNotNull(key); } @Test public void testServerWithKeyLessKeystore_EmptyPwd() { URL keyStoreUrl = ResourceUtils.getResourceWithAbsolutePackagePath("/keystores", "keyless.keystore"); SoapServer server = SoapServer.builder() .httpsPort(9696) .keyStoreUrl(keyStoreUrl) .keyStorePassword("") .build(); server.start(); server.stop(); } @Test(expected = SoapServerException.class) public void testServerWithKeyLessKeystore_NullPwd() { URL keyStoreUrl = ResourceUtils.getResourceWithAbsolutePackagePath("/keystores", "keyless.keystore"); SoapServer server = SoapServer.builder() .httpsPort(9696) .keyStoreUrl(keyStoreUrl) .keyStorePassword(null) .build(); server.start(); server.stop(); } @Test(expected = SoapServerException.class) public void testServerWithKeyLessKeystore_WrongPwd() { URL keyStoreUrl = ResourceUtils.getResourceWithAbsolutePackagePath("/keystores", "keyless.keystore"); SoapServer server = SoapServer.builder() .httpsPort(9696) .keyStoreUrl(keyStoreUrl) .keyStorePassword("wrong_password") .build(); server.start(); server.stop(); } } ================================================ FILE: soap-server/src/test/java/org/reficio/ws/server/SimpleServerTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.server; import org.junit.Test; import org.reficio.ws.server.core.SoapServer; import org.reficio.ws.server.responder.RequestResponder; import org.springframework.ws.soap.SoapMessage; import javax.xml.transform.Source; import java.io.IOException; import java.net.DatagramSocket; import java.net.ServerSocket; import java.util.List; import static junit.framework.Assert.assertFalse; import static org.junit.Assert.*; /** * @author Tom Bujok * @since 1.0.0 */ public class SimpleServerTest { public static boolean isPortAvailable(int port) { ServerSocket ss = null; DatagramSocket ds = null; try { ss = new ServerSocket(port); ss.setReuseAddress(true); ds = new DatagramSocket(port); ds.setReuseAddress(true); return true; } catch (IOException e) { } finally { if (ds != null) { ds.close(); } if (ss != null) { try { ss.close(); } catch (IOException e) { } } } return false; } public static int getFreePort() { for (int portToCheck = 20000; portToCheck < 21000; portToCheck++) { if (isPortAvailable(portToCheck)) { return portToCheck; } } throw new SoapServerException("Crazy stuff is happening, no free port available"); } public static SoapServer getServer() { SoapServer server = SoapServer.builder() .httpPort(getFreePort()) .build(); return server; } @Test public void startStop() { int port = getFreePort(); assertTrue(isPortAvailable(port)); SoapServer server = SoapServer.builder() .httpPort(port) .build(); server.start(); assertFalse(isPortAvailable(port)); server.stop(); assertTrue(isPortAvailable(port)); } @Test public void startStopDestroy() { SoapServer server = getServer(); server.start(); server.stop(); server.destroy(); } @Test public void startStopDestroyCannotResurrect() { SoapServer server = getServer(); server.start(); server.stop(); server.destroy(); RuntimeException caught = null; try { server.start(); } catch (RuntimeException ex) { caught = ex; } assertNotNull(caught); } @Test public void registerCheck() { String contextPath = "/test"; SoapServer server = getServer(); server.registerRequestResponder(contextPath, new RequestResponder() { @Override public Source respond(SoapMessage message) { return null; } }); List paths = server.getRegisteredContextPaths(); assertEquals(paths.size(), 1); assertEquals(paths.toArray(new String[]{})[0], contextPath); } @Test public void unregisterCheck() { String contextPath = "/test"; SoapServer server = getServer(); server.registerRequestResponder(contextPath, new RequestResponder() { @Override public Source respond(SoapMessage message) { return null; } }); server.unregisterRequestResponder(contextPath); List paths = server.getRegisteredContextPaths(); assertEquals(paths.size(), 0); } @Test(expected = ServiceRegistrationException.class) public void doubleRegister() { String contextPath = "/test"; SoapServer server = getServer(); server.registerRequestResponder(contextPath, new RequestResponder() { @Override public Source respond(SoapMessage message) { return null; } }); server.registerRequestResponder(contextPath, new RequestResponder() { @Override public Source respond(SoapMessage message) { return null; } }); } @Test(expected = NullPointerException.class) public void registerNullResponder() { String contextPath = "/test"; SoapServer server = getServer(); server.registerRequestResponder(contextPath, null); } @Test(expected = NullPointerException.class) public void registerNullContextPath() { SoapServer server = getServer(); server.registerRequestResponder(null, new RequestResponder() { @Override public Source respond(SoapMessage message) { return null; } }); } @Test(expected = ServiceRegistrationException.class) public void unregisterNotExisting() { String contextPath = "/test"; SoapServer server = getServer(); server.unregisterRequestResponder(contextPath); } } ================================================ FILE: soap-server/src/test/resources/keystores/gen.sh ================================================ #!/bin/bash keytool -genkey -keystore .keystore -alias john -storepass changeit -keypass changeit -dname "CN=John Smith, OU=Development, O=Standard Supplies Inc., L=Anytown, S=North Carolina, C=US" keytool -genkey -keystore .keystore -alias george -storepass changeit -keypass changeit -dname "CN=George Kowalski, OU=Development, O=Standard Supplies Inc., L=Anytown, S=North Carolina, C=US" ================================================ FILE: soap-server/src/test/resources/log4j.xml ================================================ ================================================ FILE: soap-test/pom.xml ================================================ 4.0.0 org.reficio soap-test soap-test - soap testing tools org.reficio soap-ws 1.0.0-SNAPSHOT ../pom.xml org.reficio soap-client ${project.version} org.reficio soap-server ${project.version} junit junit 4.11 provided org.spockframework spock-core 0.7-groovy-2.0 provided ================================================ FILE: soap-test/src/main/groovy/org/reficio/ws/test/spock/Server.groovy ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.test.spock import org.spockframework.runtime.extension.ExtensionAnnotation import java.lang.annotation.ElementType import java.lang.annotation.Retention import java.lang.annotation.RetentionPolicy import java.lang.annotation.Target /** * @author: Tom Bujok (tom.bujok@gmail.com) * * Reficio™ - Reestablish your software! * www.reficio.org */ @Retention(RetentionPolicy.RUNTIME) @Target([ElementType.METHOD, ElementType.TYPE]) @ExtensionAnnotation(ServerExtension) @interface Server { String wsdl(); String binding(); String path() default "/service"; int port() default 51515; } ================================================ FILE: soap-test/src/main/groovy/org/reficio/ws/test/spock/ServerExtension.groovy ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.test.spock import org.reficio.ws.test.ServerProcessor import org.spockframework.runtime.AbstractRunListener import org.spockframework.runtime.extension.AbstractAnnotationDrivenExtension import org.spockframework.runtime.model.FeatureInfo import org.spockframework.runtime.model.SpecInfo /** * @author: Tom Bujok (tom.bujok@gmail.com) * * Reficio™ - Reestablish your software! * www.reficio.org */ class ServerExtension extends AbstractAnnotationDrivenExtension { def featureAnnotations = [:] void visitSpecAnnotation(Server annotation, SpecInfo spec) { spec.addListener(new AbstractRunListener() { private ServerProcessor processor @Override public void beforeSpec(SpecInfo specInfo) { processor = new ServerProcessor(annotation, spec.getClass()) processor.initServer() } @Override public void afterSpec(SpecInfo specInfo) { processor.stopServer() } }); } void visitFeatureAnnotation(Server annotation, FeatureInfo feature) { if (featureAnnotations.isEmpty()) { feature.getParent().addListener(new AbstractRunListener() { @Override public void beforeFeature(FeatureInfo featureInfo) { ServerProcessor processor = featureAnnotations[featureInfo] if (processor) { processor.initServer() } } @Override public void afterFeature(FeatureInfo featureInfo) { ServerProcessor processor = featureAnnotations[featureInfo] if (processor) { processor.stopServer() } } }); } featureAnnotations[feature] = new ServerProcessor(annotation, feature.getClass()) } } ================================================ FILE: soap-test/src/main/java/org/reficio/ws/test/ServerProcessor.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.test; import com.google.common.base.Preconditions; import org.reficio.ws.SoapContext; import org.reficio.ws.SoapException; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.core.Wsdl; import org.reficio.ws.common.ResourceUtils; import org.reficio.ws.server.core.SoapServer; import org.reficio.ws.server.responder.AutoResponder; import java.net.MalformedURLException; import java.net.URL; /** * @author: Tom Bujok (tom.bujok@gmail.com) *

* Reficio™ - Reestablish your software! * www.reficio.org */ public class ServerProcessor { private SoapServer server; private final String wsdl; private final String binding; private final String path; private final int port; private final Class testClass; public ServerProcessor(org.reficio.ws.test.junit.Server server, Class testClass) { this.wsdl = processUrl(server.wsdl()); this.binding = server.binding(); this.path = server.path(); this.port = server.port(); this.testClass = testClass; } public ServerProcessor(org.reficio.ws.test.spock.Server server, Class testClass) { this.wsdl = processUrl(server.wsdl()); this.binding = server.binding(); this.path = server.path(); this.port = server.port(); this.testClass = testClass; } private String processUrl(String wsdlUrl) { if(wsdlUrl == null) { return null; } if(wsdlUrl.startsWith("classpath:")) { return ResourceUtils.getResource(wsdlUrl.replace("classpath:","")).toString(); } else { return wsdlUrl; } } public SoapServer initServer() { validate(); URL wsdlUrl = getWsdlUrl(testClass); Wsdl parser = Wsdl.parse(wsdlUrl); SoapBuilder builder = getBuilder(parser); server = construct(); AutoResponder responder = getAutoResponder(builder); registerService(server, responder); server.start(); return server; } public void stopServer() { if (server != null) { server.stop(); } } private SoapServer construct() { return SoapServer.builder() .httpPort(port) .build(); } private void registerService(SoapServer server, AutoResponder responder) { server.registerRequestResponder(path, responder); } private AutoResponder getAutoResponder(SoapBuilder builder) { SoapContext context = SoapContext.builder() .exampleContent(true) .buildOptional(true) .alwaysBuildHeaders(true) .build(); return new AutoResponder(builder, context); } private SoapBuilder getBuilder(Wsdl parser) { SoapBuilder builder = null; try { builder = parser.binding().name(binding).find(); } catch (SoapException ex) { // ignore } if (builder == null) { builder = parser.binding().localPart(binding).find(); } Preconditions.checkNotNull(builder, "Binding not found"); return builder; } private URL getWsdlUrl(Class testClass) { URL wsdlUrl = null; try { wsdlUrl = ResourceUtils.getResource(testClass, wsdl); } catch (IllegalArgumentException ex) { // ignore } if (wsdlUrl == null) { try { wsdlUrl = new URL(wsdl); } catch (MalformedURLException e) { throw new IllegalArgumentException("Wrong wsdl url", e); } } return wsdlUrl; } private void validate() { Preconditions.checkNotNull(wsdl, "Wsdl url cannot be null"); Preconditions.checkNotNull(binding, "Binding name cannot be null"); Preconditions.checkArgument(port >= 0 && port < 65535, "Port has to be in range [0, 655535]"); } } ================================================ FILE: soap-test/src/main/java/org/reficio/ws/test/junit/Server.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.test.junit; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Annotation specifying a SOAP mock * * @author Tom Bujok * @since 1.0.0 */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.TYPE}) public @interface Server { String wsdl(); String binding(); String path() default "/service"; int port() default 51515; } ================================================ FILE: soap-test/src/main/java/org/reficio/ws/test/junit/SoapRule.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.test.junit; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; import org.reficio.ws.test.ServerProcessor; /** * @author Tom Bujok * @since 1.0.0 */ public class SoapRule implements TestRule { @Override public Statement apply(Statement base, Description description) { return statement(base, description); } private Statement statement(final Statement base, final Description description) { return new Statement() { @Override public void evaluate() throws Throwable { Server server = description.getAnnotation(Server.class); ServerProcessor processor = null; if (server != null) { Class testClass = description.getTestClass(); processor = new ServerProcessor(server, testClass); processor.initServer(); } try { base.evaluate(); } finally { if (processor != null) { processor.stopServer(); } } } }; } } ================================================ FILE: soap-test/src/test/groovy/org/reficio/ws/test/spock/SpockExtensionTest.groovy ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.test.spock import groovy.util.logging.Log4j import org.reficio.ws.builder.SoapBuilder import org.reficio.ws.builder.SoapOperation import org.reficio.ws.builder.core.Wsdl import org.reficio.ws.client.core.SoapClient import org.reficio.ws.common.ResourceUtils import spock.lang.Specification @Log4j @Server(wsdl = "classpath:wsdl/currency-convertor.wsdl", binding = "CurrencyConvertorSoap") class SpockExtensionTest extends Specification { static final String WSDL = ResourceUtils.getResource("wsdl/currency-convertor.wsdl").toString(); @Server(wsdl = "classpath:wsdl/currency-convertor.wsdl", binding = "CurrencyConvertorSoap", port = 41414) def "method specific server"() { setup: SoapClient client = SoapClient.builder().endpointUri("http://localhost:41414/service").build(); SoapBuilder builder = Wsdl.parse(WSDL).binding().localPart("CurrencyConvertorSoap").find(); SoapOperation operation = builder.operation().name("ConversionRate").find(); String request = builder.buildInputMessage(operation); log.info("\n" + request); when: String response = client.post(request); then: assert response != null log.info("\n" + response); } def "test specific server"() { setup: SoapClient client = SoapClient.builder().endpointUri("http://localhost:51515/service").build(); SoapBuilder builder = Wsdl.parse(WSDL).binding().localPart("CurrencyConvertorSoap").find(); SoapOperation operation = builder.operation().name("ConversionRate").find(); String request = builder.buildInputMessage(operation); log.info("\n" + request); when: String response = client.post(request); then: assert response != null log.info("\n" + response); } } ================================================ FILE: soap-test/src/test/java/org/reficio/ws/test/junit/SoapRuleTest.java ================================================ /** * Copyright (c) 2012-2013 Reficio (TM) - Reestablish your software!. All Rights Reserved. * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.reficio.ws.test.junit; import org.apache.log4j.Logger; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.reficio.ws.builder.SoapBuilder; import org.reficio.ws.builder.SoapOperation; import org.reficio.ws.builder.core.Wsdl; import org.reficio.ws.client.core.SoapClient; import org.reficio.ws.common.ResourceUtils; // @Server annotation spawns an instance of a SoapServer for the lifespan of the test / method. // The SOAP server provides a SOAP auto-responder for the specified binding -> messages are generated and send automatically. // Generated messages are compliant with the WSDL and the schema (including enumerations, etc.) // The @Server annotation may be also used to annotate a method -> it spawns a SoapServer for the lifespan of the test method. // In order to enable the @Server annotation a junit @Rule has to be defined (JUnit requirement): // - org.junit.ClassRule in order to enable the @Server on a per-class basis // - org.junit.Rule in order to enable the @Server on a per-class basis @Server(wsdl = "classpath:wsdl/currency-convertor.wsdl", binding = "CurrencyConvertorSoap") public class SoapRuleTest { private final static Logger log = Logger.getLogger(SoapRuleTest.class); private static final String WSDL = ResourceUtils.getResource("wsdl/currency-convertor.wsdl").toString(); @Rule // define an instance rule if the @Server annotation is used per method public SoapRule rule = new SoapRule(); @ClassRule // define a class rule if the @Server annotation is used per class public static SoapRule classRule = new SoapRule(); @Test @Server(wsdl = "classpath:wsdl/currency-convertor.wsdl", binding = "CurrencyConvertorSoap", port = 41414) public void testSoapMock_perMethodServer() { SoapClient client = SoapClient.builder().endpointUri("http://localhost:41414/service").build(); SoapBuilder builder = Wsdl.parse(WSDL).binding().localPart("CurrencyConvertorSoap").find(); SoapOperation operation = builder.operation().name("ConversionRate").find(); String request = builder.buildInputMessage(operation); log.info("\n" + request); String response = client.post(request); log.info("\n" + response); } @Test public void testSoapMock_perClassServer() { SoapClient client = SoapClient.builder().endpointUri("http://localhost:51515/service").build(); SoapBuilder builder = Wsdl.parse(WSDL).binding().localPart("CurrencyConvertorSoap").find(); SoapOperation operation = builder.operation().name("ConversionRate").find(); String request = builder.buildInputMessage(operation); log.info("\n" + request); String response = client.post(request); log.info("\n" + response); } } ================================================ FILE: soap-test/src/test/resources/log4j.xml ================================================ ================================================ FILE: soap-test/src/test/resources/wsdl/TestService.wsdl ================================================ Read page data from Test Read page children from Test Find pages that has special properties Save page data to Test Returns true for signed and authenticated messages and false for unsigned messages Delete a page version Delete a page Delete page children Move a page Copy a page ================================================ FILE: soap-test/src/test/resources/wsdl/currency-convertor.wsdl ================================================ <br><b>Get conversion rate from one currency to another currency <b><br><p><b><font color='#000080' size='1' face='Verdana'><u>Differenct currency Code and Names around the world</u></font></b></p><blockquote><p><font face='Verdana' size='1'>AFA-Afghanistan Afghani<br>ALL-Albanian Lek<br>DZD-Algerian Dinar<br>ARS-Argentine Peso<br>AWG-Aruba Florin<br>AUD-Australian Dollar<br>BSD-Bahamian Dollar<br>BHD-Bahraini Dinar<br>BDT-Bangladesh Taka<br>BBD-Barbados Dollar<br>BZD-Belize Dollar<br>BMD-Bermuda Dollar<br>BTN-Bhutan Ngultrum<br>BOB-Bolivian Boliviano<br>BWP-Botswana Pula<br>BRL-Brazilian Real<br>GBP-British Pound<br>BND-Brunei Dollar<br>BIF-Burundi Franc<br>XOF-CFA Franc (BCEAO)<br>XAF-CFA Franc (BEAC)<br>KHR-Cambodia Riel<br>CAD-Canadian Dollar<br>CVE-Cape Verde Escudo<br>KYD-Cayman Islands Dollar<br>CLP-Chilean Peso<br>CNY-Chinese Yuan<br>COP-Colombian Peso<br>KMF-Comoros Franc<br>CRC-Costa Rica Colon<br>HRK-Croatian Kuna<br>CUP-Cuban Peso<br>CYP-Cyprus Pound<br>CZK-Czech Koruna<br>DKK-Danish Krone<br>DJF-Dijibouti Franc<br>DOP-Dominican Peso<br>XCD-East Caribbean Dollar<br>EGP-Egyptian Pound<br>SVC-El Salvador Colon<br>EEK-Estonian Kroon<br>ETB-Ethiopian Birr<br>EUR-Euro<br>FKP-Falkland Islands Pound<br>GMD-Gambian Dalasi<br>GHC-Ghanian Cedi<br>GIP-Gibraltar Pound<br>XAU-Gold Ounces<br>GTQ-Guatemala Quetzal<br>GNF-Guinea Franc<br>GYD-Guyana Dollar<br>HTG-Haiti Gourde<br>HNL-Honduras Lempira<br>HKD-Hong Kong Dollar<br>HUF-Hungarian Forint<br>ISK-Iceland Krona<br>INR-Indian Rupee<br>IDR-Indonesian Rupiah<br>IQD-Iraqi Dinar<br>ILS-Israeli Shekel<br>JMD-Jamaican Dollar<br>JPY-Japanese Yen<br>JOD-Jordanian Dinar<br>KZT-Kazakhstan Tenge<br>KES-Kenyan Shilling<br>KRW-Korean Won<br>KWD-Kuwaiti Dinar<br>LAK-Lao Kip<br>LVL-Latvian Lat<br>LBP-Lebanese Pound<br>LSL-Lesotho Loti<br>LRD-Liberian Dollar<br>LYD-Libyan Dinar<br>LTL-Lithuanian Lita<br>MOP-Macau Pataca<br>MKD-Macedonian Denar<br>MGF-Malagasy Franc<br>MWK-Malawi Kwacha<br>MYR-Malaysian Ringgit<br>MVR-Maldives Rufiyaa<br>MTL-Maltese Lira<br>MRO-Mauritania Ougulya<br>MUR-Mauritius Rupee<br>MXN-Mexican Peso<br>MDL-Moldovan Leu<br>MNT-Mongolian Tugrik<br>MAD-Moroccan Dirham<br>MZM-Mozambique Metical<br>MMK-Myanmar Kyat<br>NAD-Namibian Dollar<br>NPR-Nepalese Rupee<br>ANG-Neth Antilles Guilder<br>NZD-New Zealand Dollar<br>NIO-Nicaragua Cordoba<br>NGN-Nigerian Naira<br>KPW-North Korean Won<br>NOK-Norwegian Krone<br>OMR-Omani Rial<br>XPF-Pacific Franc<br>PKR-Pakistani Rupee<br>XPD-Palladium Ounces<br>PAB-Panama Balboa<br>PGK-Papua New Guinea Kina<br>PYG-Paraguayan Guarani<br>PEN-Peruvian Nuevo Sol<br>PHP-Philippine Peso<br>XPT-Platinum Ounces<br>PLN-Polish Zloty<br>QAR-Qatar Rial<br>ROL-Romanian Leu<br>RUB-Russian Rouble<br>WST-Samoa Tala<br>STD-Sao Tome Dobra<br>SAR-Saudi Arabian Riyal<br>SCR-Seychelles Rupee<br>SLL-Sierra Leone Leone<br>XAG-Silver Ounces<br>SGD-Singapore Dollar<br>SKK-Slovak Koruna<br>SIT-Slovenian Tolar<br>SBD-Solomon Islands Dollar<br>SOS-Somali Shilling<br>ZAR-South African Rand<br>LKR-Sri Lanka Rupee<br>SHP-St Helena Pound<br>SDD-Sudanese Dinar<br>SRG-Surinam Guilder<br>SZL-Swaziland Lilageni<br>SEK-Swedish Krona<br>TRY-Turkey Lira<br>CHF-Swiss Franc<br>SYP-Syrian Pound<br>TWD-Taiwan Dollar<br>TZS-Tanzanian Shilling<br>THB-Thai Baht<br>TOP-Tonga Pa'anga<br>TTD-Trinidad&amp;amp;Tobago Dollar<br>TND-Tunisian Dinar<br>TRL-Turkish Lira<br>USD-U.S. Dollar<br>AED-UAE Dirham<br>UGX-Ugandan Shilling<br>UAH-Ukraine Hryvnia<br>UYU-Uruguayan New Peso<br>VUV-Vanuatu Vatu<br>VEB-Venezuelan Bolivar<br>VND-Vietnam Dong<br>YER-Yemen Riyal<br>YUM-Yugoslav Dinar<br>ZMK-Zambian Kwacha<br>ZWD-Zimbabwe Dollar</font></p></blockquote> <br><b>Get conversion rate from one currency to another currency <b><br><p><b><font color='#000080' size='1' face='Verdana'><u>Differenct currency Code and Names around the world</u></font></b></p><blockquote><p><font face='Verdana' size='1'>AFA-Afghanistan Afghani<br>ALL-Albanian Lek<br>DZD-Algerian Dinar<br>ARS-Argentine Peso<br>AWG-Aruba Florin<br>AUD-Australian Dollar<br>BSD-Bahamian Dollar<br>BHD-Bahraini Dinar<br>BDT-Bangladesh Taka<br>BBD-Barbados Dollar<br>BZD-Belize Dollar<br>BMD-Bermuda Dollar<br>BTN-Bhutan Ngultrum<br>BOB-Bolivian Boliviano<br>BWP-Botswana Pula<br>BRL-Brazilian Real<br>GBP-British Pound<br>BND-Brunei Dollar<br>BIF-Burundi Franc<br>XOF-CFA Franc (BCEAO)<br>XAF-CFA Franc (BEAC)<br>KHR-Cambodia Riel<br>CAD-Canadian Dollar<br>CVE-Cape Verde Escudo<br>KYD-Cayman Islands Dollar<br>CLP-Chilean Peso<br>CNY-Chinese Yuan<br>COP-Colombian Peso<br>KMF-Comoros Franc<br>CRC-Costa Rica Colon<br>HRK-Croatian Kuna<br>CUP-Cuban Peso<br>CYP-Cyprus Pound<br>CZK-Czech Koruna<br>DKK-Danish Krone<br>DJF-Dijibouti Franc<br>DOP-Dominican Peso<br>XCD-East Caribbean Dollar<br>EGP-Egyptian Pound<br>SVC-El Salvador Colon<br>EEK-Estonian Kroon<br>ETB-Ethiopian Birr<br>EUR-Euro<br>FKP-Falkland Islands Pound<br>GMD-Gambian Dalasi<br>GHC-Ghanian Cedi<br>GIP-Gibraltar Pound<br>XAU-Gold Ounces<br>GTQ-Guatemala Quetzal<br>GNF-Guinea Franc<br>GYD-Guyana Dollar<br>HTG-Haiti Gourde<br>HNL-Honduras Lempira<br>HKD-Hong Kong Dollar<br>HUF-Hungarian Forint<br>ISK-Iceland Krona<br>INR-Indian Rupee<br>IDR-Indonesian Rupiah<br>IQD-Iraqi Dinar<br>ILS-Israeli Shekel<br>JMD-Jamaican Dollar<br>JPY-Japanese Yen<br>JOD-Jordanian Dinar<br>KZT-Kazakhstan Tenge<br>KES-Kenyan Shilling<br>KRW-Korean Won<br>KWD-Kuwaiti Dinar<br>LAK-Lao Kip<br>LVL-Latvian Lat<br>LBP-Lebanese Pound<br>LSL-Lesotho Loti<br>LRD-Liberian Dollar<br>LYD-Libyan Dinar<br>LTL-Lithuanian Lita<br>MOP-Macau Pataca<br>MKD-Macedonian Denar<br>MGF-Malagasy Franc<br>MWK-Malawi Kwacha<br>MYR-Malaysian Ringgit<br>MVR-Maldives Rufiyaa<br>MTL-Maltese Lira<br>MRO-Mauritania Ougulya<br>MUR-Mauritius Rupee<br>MXN-Mexican Peso<br>MDL-Moldovan Leu<br>MNT-Mongolian Tugrik<br>MAD-Moroccan Dirham<br>MZM-Mozambique Metical<br>MMK-Myanmar Kyat<br>NAD-Namibian Dollar<br>NPR-Nepalese Rupee<br>ANG-Neth Antilles Guilder<br>NZD-New Zealand Dollar<br>NIO-Nicaragua Cordoba<br>NGN-Nigerian Naira<br>KPW-North Korean Won<br>NOK-Norwegian Krone<br>OMR-Omani Rial<br>XPF-Pacific Franc<br>PKR-Pakistani Rupee<br>XPD-Palladium Ounces<br>PAB-Panama Balboa<br>PGK-Papua New Guinea Kina<br>PYG-Paraguayan Guarani<br>PEN-Peruvian Nuevo Sol<br>PHP-Philippine Peso<br>XPT-Platinum Ounces<br>PLN-Polish Zloty<br>QAR-Qatar Rial<br>ROL-Romanian Leu<br>RUB-Russian Rouble<br>WST-Samoa Tala<br>STD-Sao Tome Dobra<br>SAR-Saudi Arabian Riyal<br>SCR-Seychelles Rupee<br>SLL-Sierra Leone Leone<br>XAG-Silver Ounces<br>SGD-Singapore Dollar<br>SKK-Slovak Koruna<br>SIT-Slovenian Tolar<br>SBD-Solomon Islands Dollar<br>SOS-Somali Shilling<br>ZAR-South African Rand<br>LKR-Sri Lanka Rupee<br>SHP-St Helena Pound<br>SDD-Sudanese Dinar<br>SRG-Surinam Guilder<br>SZL-Swaziland Lilageni<br>SEK-Swedish Krona<br>TRY-Turkey Lira<br>CHF-Swiss Franc<br>SYP-Syrian Pound<br>TWD-Taiwan Dollar<br>TZS-Tanzanian Shilling<br>THB-Thai Baht<br>TOP-Tonga Pa'anga<br>TTD-Trinidad&amp;amp;Tobago Dollar<br>TND-Tunisian Dinar<br>TRL-Turkish Lira<br>USD-U.S. Dollar<br>AED-UAE Dirham<br>UGX-Ugandan Shilling<br>UAH-Ukraine Hryvnia<br>UYU-Uruguayan New Peso<br>VUV-Vanuatu Vatu<br>VEB-Venezuelan Bolivar<br>VND-Vietnam Dong<br>YER-Yemen Riyal<br>YUM-Yugoslav Dinar<br>ZMK-Zambian Kwacha<br>ZWD-Zimbabwe Dollar</font></p></blockquote> <br><b>Get conversion rate from one currency to another currency <b><br><p><b><font color='#000080' size='1' face='Verdana'><u>Differenct currency Code and Names around the world</u></font></b></p><blockquote><p><font face='Verdana' size='1'>AFA-Afghanistan Afghani<br>ALL-Albanian Lek<br>DZD-Algerian Dinar<br>ARS-Argentine Peso<br>AWG-Aruba Florin<br>AUD-Australian Dollar<br>BSD-Bahamian Dollar<br>BHD-Bahraini Dinar<br>BDT-Bangladesh Taka<br>BBD-Barbados Dollar<br>BZD-Belize Dollar<br>BMD-Bermuda Dollar<br>BTN-Bhutan Ngultrum<br>BOB-Bolivian Boliviano<br>BWP-Botswana Pula<br>BRL-Brazilian Real<br>GBP-British Pound<br>BND-Brunei Dollar<br>BIF-Burundi Franc<br>XOF-CFA Franc (BCEAO)<br>XAF-CFA Franc (BEAC)<br>KHR-Cambodia Riel<br>CAD-Canadian Dollar<br>CVE-Cape Verde Escudo<br>KYD-Cayman Islands Dollar<br>CLP-Chilean Peso<br>CNY-Chinese Yuan<br>COP-Colombian Peso<br>KMF-Comoros Franc<br>CRC-Costa Rica Colon<br>HRK-Croatian Kuna<br>CUP-Cuban Peso<br>CYP-Cyprus Pound<br>CZK-Czech Koruna<br>DKK-Danish Krone<br>DJF-Dijibouti Franc<br>DOP-Dominican Peso<br>XCD-East Caribbean Dollar<br>EGP-Egyptian Pound<br>SVC-El Salvador Colon<br>EEK-Estonian Kroon<br>ETB-Ethiopian Birr<br>EUR-Euro<br>FKP-Falkland Islands Pound<br>GMD-Gambian Dalasi<br>GHC-Ghanian Cedi<br>GIP-Gibraltar Pound<br>XAU-Gold Ounces<br>GTQ-Guatemala Quetzal<br>GNF-Guinea Franc<br>GYD-Guyana Dollar<br>HTG-Haiti Gourde<br>HNL-Honduras Lempira<br>HKD-Hong Kong Dollar<br>HUF-Hungarian Forint<br>ISK-Iceland Krona<br>INR-Indian Rupee<br>IDR-Indonesian Rupiah<br>IQD-Iraqi Dinar<br>ILS-Israeli Shekel<br>JMD-Jamaican Dollar<br>JPY-Japanese Yen<br>JOD-Jordanian Dinar<br>KZT-Kazakhstan Tenge<br>KES-Kenyan Shilling<br>KRW-Korean Won<br>KWD-Kuwaiti Dinar<br>LAK-Lao Kip<br>LVL-Latvian Lat<br>LBP-Lebanese Pound<br>LSL-Lesotho Loti<br>LRD-Liberian Dollar<br>LYD-Libyan Dinar<br>LTL-Lithuanian Lita<br>MOP-Macau Pataca<br>MKD-Macedonian Denar<br>MGF-Malagasy Franc<br>MWK-Malawi Kwacha<br>MYR-Malaysian Ringgit<br>MVR-Maldives Rufiyaa<br>MTL-Maltese Lira<br>MRO-Mauritania Ougulya<br>MUR-Mauritius Rupee<br>MXN-Mexican Peso<br>MDL-Moldovan Leu<br>MNT-Mongolian Tugrik<br>MAD-Moroccan Dirham<br>MZM-Mozambique Metical<br>MMK-Myanmar Kyat<br>NAD-Namibian Dollar<br>NPR-Nepalese Rupee<br>ANG-Neth Antilles Guilder<br>NZD-New Zealand Dollar<br>NIO-Nicaragua Cordoba<br>NGN-Nigerian Naira<br>KPW-North Korean Won<br>NOK-Norwegian Krone<br>OMR-Omani Rial<br>XPF-Pacific Franc<br>PKR-Pakistani Rupee<br>XPD-Palladium Ounces<br>PAB-Panama Balboa<br>PGK-Papua New Guinea Kina<br>PYG-Paraguayan Guarani<br>PEN-Peruvian Nuevo Sol<br>PHP-Philippine Peso<br>XPT-Platinum Ounces<br>PLN-Polish Zloty<br>QAR-Qatar Rial<br>ROL-Romanian Leu<br>RUB-Russian Rouble<br>WST-Samoa Tala<br>STD-Sao Tome Dobra<br>SAR-Saudi Arabian Riyal<br>SCR-Seychelles Rupee<br>SLL-Sierra Leone Leone<br>XAG-Silver Ounces<br>SGD-Singapore Dollar<br>SKK-Slovak Koruna<br>SIT-Slovenian Tolar<br>SBD-Solomon Islands Dollar<br>SOS-Somali Shilling<br>ZAR-South African Rand<br>LKR-Sri Lanka Rupee<br>SHP-St Helena Pound<br>SDD-Sudanese Dinar<br>SRG-Surinam Guilder<br>SZL-Swaziland Lilageni<br>SEK-Swedish Krona<br>TRY-Turkey Lira<br>CHF-Swiss Franc<br>SYP-Syrian Pound<br>TWD-Taiwan Dollar<br>TZS-Tanzanian Shilling<br>THB-Thai Baht<br>TOP-Tonga Pa'anga<br>TTD-Trinidad&amp;amp;Tobago Dollar<br>TND-Tunisian Dinar<br>TRL-Turkish Lira<br>USD-U.S. Dollar<br>AED-UAE Dirham<br>UGX-Ugandan Shilling<br>UAH-Ukraine Hryvnia<br>UYU-Uruguayan New Peso<br>VUV-Vanuatu Vatu<br>VEB-Venezuelan Bolivar<br>VND-Vietnam Dong<br>YER-Yemen Riyal<br>YUM-Yugoslav Dinar<br>ZMK-Zambian Kwacha<br>ZWD-Zimbabwe Dollar</font></p></blockquote> ================================================ FILE: soap-test/src/test/resources/wsdl/testservice1.xsd ================================================ ================================================ FILE: soap-test/src/test/resources/wsdl/testservice2.xsd ================================================

test test

]]> WorkID is good to h ================================================ FILE: src/main/resources/findbugs-exclude.xml ================================================ ================================================ FILE: src/main/resources/license.txt ================================================ Copyright (c) ${year} ${company}. All Rights Reserved. Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: src/site/fml/faq.fml ================================================ General What is soap-ws?

soap-ws is a lightweight and easy-to-use Java library to handle SOAP message generation and SOAP message transmission on a purely XML level. With the usage of this library within few lines of code you can easily import your WSDL and generate SOAP messages directly in an XML format. Then you can use the SoapClient to transmit this message over HTTP(s) to a web-service endpoint. Finally, you can run SoapServer to receive SOAP messages and and respond to them. And all of that requires no classes or stubs generation - everything happens directly in an XML format.

What should I bother? Have a look at this:
  • Have you ever had problems with the versioning of web-service endpoints? Have you ever had to address the problem how to deal with many versions of the same classes generated from two versions of the same WSDL in one code base? Did you try to prefix the classes, change the package, or do any other mambo-jumbo tricks that are clearly against the best-practices of software design?
  • Have you every tried to chain and orchestrate a few web-service invocations applying some XSLT transformation to the consecutive responses forwarding them to the next endpoint? Have you ever seen how cumbersome it is using Java generated ws clients/servers?
  • Have you ever had to re-generate the ws-stubs, recompile and redeploy you application because of a tiny change in the WSDL?
  • Have you every been confused why you generate all these domain and stub classes to invoke one simple web-service operation and to get a plain response that could be processed with XSTL one-liner?
  • Have you ever had to had to send a simple XML message to a SOAP server in a fire and forget mode?
  • Have you ever had to expose a mock SOAP endpoint that would respond to the request sending a sample response -let's say in an unit test?
  • Have you ever had to download a hierarchical WSDL file with hierarchical XSD schemas and store it on your local hard drive with all the import and includes fixed properly so that you can reuse it locally?
  • Have you ever…

Yes, that's what soap-ws can do for you. But it can do much more, just dive in and check the plethora of stuff that we have implemented.

How can I hack around? Try here:
  • GitHub -> https://github.com/reficio/soap-ws
  • Jenkins -> https://reficio.ci.cloudbees.com/job/soap-ws
  • Site -> http://projects.reficio.org/soap-ws/1.0.0-SNAPSHOT
================================================ FILE: src/site/site.xml ================================================ org.reficio maven-skin 1.0.0 $reports