on 01-28-2016 5:21 PM
Hi, experts!
We need to implement SOAP web-service on Hybris B2B v.5.1. On this page https://wiki.hybris.com/display/release5/Deprecated+extensions+5.0#Deprecatedextensions5.0-soapsprin... saids that "The soapspring 4.7 is fully compatible with the platform 5.0". Could anybody share extention "soapspring"? On wiki download link deactivated.
Thanks!
We implemented own SOAP web-service with HTTPS nd Basic authentication.
1.Create extention "webservices" via Ant extgen. Template yempty.
2.Create java class WebService.java:
.
@WebService
@SOAPBinding(style = Style.DOCUMENT)
public class DhWebService
{
public String test()
{
// Выполнить обработку...
System.out.println("Hello");
return "Hello World JAX-WS";
}
}
3.Create file sun-jaxws.xml in webservices\web\webroot\WEB-INF\ folder:
<?xml version="1.0" encoding="UTF-8"?>
<endpoints
xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
<endpoint
name="WebService"
implementation="org.webservices.WebService"
url-pattern="/ws"/>
</endpoints>
4.In webservices\web\webroot\WEB-INF\web.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<web-app id="webservices" version="3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
metadata-complete="true">
<absolute-ordering />
<display-name>webservices</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- HTTPS Basic Auth -->
<security-role>
<description>b2bcustomergroup</description>
<role-name>b2bcustomergroup</role-name>
</security-role>
<resource-ref>
<res-ref-name>hybrisDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<security-constraint>
<web-resource-collection>
<web-resource-name>Means whole app requires authentication</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>customer</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<!-- End HTTPS Basic Auth -->
<filter>
<filter-name>XSSFilter</filter-name>
<filter-class>de.hybris.platform.servicelayer.web.XSSFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>XSSFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter>
<filter-name>webservicesPlatformFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>webservicesPlatformFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/webservices-web-spring.xml</param-value>
</context-param>
<listener>
<listener-class>de.hybris.platform.spring.HybrisContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!-- web-service description -->
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>universal</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>universal</servlet-name>
<url-pattern>/ws</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>300</session-timeout><!-- 300 = 5 minutes -->
</session-config>
<!-- End Web-service description-->
</web-app>
5.from https://jax-ws.java.net/2.2.10/ download jars and insert in lib folder of webservices extention:
gmbal-api-only.jar
jaxb-core.jar
jaxb-impl.jar
jaxws-api.jar
jaxws-rt.jar
jaxws-spring-1.9.jar
management-api.jar
policy.jar
stax-ex.jar
streambuffer.jar
xbean-spring-3.9.jar
6.For basic authentication you need select type of store users i tomcat. It may be via config file tomcat-users.xml or via database. For database we uncomment resource "HybrisDS" in config\tomcat\conf\server.xml and add following:
<Engine name="Catalina" defaultHost="localhost">
....
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.JDBCRealm" resourceName="JDBCRealm"
driverName="${db.driver}"
connectionURL="${db.url.XMLENCODED}"
connectionName="${db.username}" connectionPassword="${db.password.XMLENCODED}"
userTable="webServiceUsersView" userNameCol="username" userCredCol="password"
userRoleTable="webServiceUsersView" roleNameCol="role"/>
</Realm>
7.Create database View webServiceUsersView where stored user for authentication:
DROP VIEW [dbo].[webServiceUsersView]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[webServiceUsersView]
AS
SELECT dbo.usergroups.uniqueid AS role, dbo.users.uniqueid AS username, dbo.users.passwd AS password
FROM dbo.pgrels INNER JOIN
dbo.users ON dbo.pgrels.SourcePK = dbo.users.PK INNER JOIN
dbo.usergroups ON dbo.pgrels.TargetPK = dbo.usergroups.PK
WHERE (dbo.users.p_active = '1') AND (dbo.usergroups.uniqueid = 'b2bcustomergroup')
GO
Now we can connect to web-service using b2bcustomergroup users.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.