Monday 19 December 2011

WSDL Binding customization example


<jaxws:bindings
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxws http://java.sun.com/xml/ns/jaxws/wsdl_customizationschema_2_0.xsd
http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
wsdlLocation="http://www.webservicex.net/stockquote.asmx?WSDL">

  <!-- JAXWS -->
  <jaxws:package name="com.company.jaxwstest.client"/>

  <!-- JAXB -->
  <!-- <jaxws:bindings node="wsdl:definitions/wsdl:types/xsd:schema"> --> 
  <jaxws:bindings node="//xsd:schema">
    <jxb:schemaBindings>
      <jxb:package name="com.company.jaxwstest.client.jaxb"/>
    </jxb:schemaBindings>
  </jaxws:bindings>
 
</jaxws:bindings>

wsgen & wsimport @ ant

<project>

  <!-- Define classpath -->

  <property name="glassfish.dir" value="C:\Programme\Java\Glassfish3\glassfish" />
  <property name="glassfish.modules.dir" value="${glassfish.dir}\modules" />

  <path id="glassfish.modules.path">
    <fileset dir="${glassfish.modules.dir}">
      <include name="**/*.jar" />
    </fileset>
  </path>

  <!-- Define tasks -->

  <taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen">
    <classpath refid="glassfish.modules.path" />
  </taskdef>

  <taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
    <classpath refid="glassfish.modules.path" />
  </taskdef>

  <!-- Define targets -->

  <target name="server">
    <wsgen keep="true" verbose="true" xendorsed="true" genwsdl="true" fork="true"
      sei="com.company.jaxwstest.server.JavaToWsdl"
      classpath="build/classes"
      destdir="build/classes"
      resourcedestdir="WebContent/WEB-INF/wsdl"
      sourcedestdir="src"/>
  </target>

  <target name="client">
    <wsimport keep="true" verbose="true" xendorsed="true" fork="true"
      wsdl="http://www.webservicex.net/stockquote.asmx?WSDL"
      destdir="build/classes"
      sourcedestdir="src"
      package="com.company.jaxwstest.client"
      binding="binding.xml"/>
  </target>

</project>

Friday 16 December 2011

Wrapper/Bare/RPC example

RPC Java:

@WebMethod(operationName = "hello")
public String sayHello(
@WebParam(name = "firstname") String nachname,
@WebParam(name = "lastname") String vorname)

RPC WSDL:

<message name="hello">
  <part name="firstname" type="xsd:string" />
  <part name="lastname" type="xsd:string" />
</message>

<message name="helloResponse">
  <part name="return" type="xsd:string" />
</message>

<portType name="testService">
  <operation name="hello">
    <input message="tns:hello" />
    <output message="tns:helloResponse" />
  </operation>
</portType>

Document/Wrapped Java (like RPC, plus generated "jaxws" wrapper classes):

@WebMethod(operationName = "hello")
public String sayHello(
@WebParam(name = "firstname") String nachname,
@WebParam(name = "lastname") String vorname)

Document/Wrapped WSDL:

<types>
  <xs:element name="hello" nillable="true" type="tns:sayHello"/>
  <xs:element name="helloResponse" nillable="true" type="tns:sayHelloResponse"/>

  <xs:complexType name="sayHello">
    <xs:sequence>
      <xs:element name="firstname" type="xs:string" minOccurs="0"/>
      <xs:element name="lastname" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="sayHelloResponse">
    <xs:sequence>
      <xs:element name="return" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
</types>

<message name="hello">
  <part name="parameters" element="tns:hello"/>
</message>

<message name="helloResponse">
  <part name="parameters" element="tns:helloResponse"/>
</message>

<portType name="testService">
  <operation name="hello">
    <input message="tns:hello"/>
    <output message="tns:helloResponse"/>
  </operation>
</portType>

Document/Bare Java (no generated class, with additional "Person" bean):

@WebMethod(operationName = "hello")
public String sayHello(Person p)

Document/Bare WSDL:

<types>
  <xs:element name="hello" nillable="true" type="tns:person"/>
  <xs:element name="helloResponse" nillable="true" type="xs:string"/>

  <xs:complexType name="person">
    <xs:sequence>
      <xs:element name="nachname" type="xs:string" minOccurs="0"/>
      <xs:element name="vorname" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
</types>

<message name="hello">
  <part name="hello" element="tns:hello"/>
</message>

<message name="helloResponse">
  <part name="helloResponse" element="tns:helloResponse"/>
</message>

<portType name="testService">
  <operation name="hello">
    <input message="tns:hello"/>
    <output message="tns:helloResponse"/>
  </operation>
</portType>

WS-I BP Clarifications

See: http://www.ws-i.org/deliverables/workinggroup.aspx?wg=basicprofile

Main points:
  • no SOAP encoding 
  • for rpc-literal bindigs, parts are defined with the "type" attribute 
  • for document-literal bindigs, parts are defined with the "element" attribute 
  • for document-literal bindings, at most one part is in the soap body
  • valid wsdl operations: one-way and request-response only
  • operation name overloading is forbidden (two operations with the same name)
  • an endpoint that supports multiple operations must unambiguously identify the operation being invoked based on the input message that it receives. This is only possible if all the operations specified in the wsdl:binding associated with an endpoint have a unique operation signature (i.e. one input message type = one operation)
  • with rpc-literal bindings, the response must have a wrapper element whose name is the corresponding wsdl:operation name suffixed with the string "Response"
  •  with rpc-literal bindings, the wrapper elements for parameters and return value have no namespace

WSDL History

WSDL 1.2 was renamed to WSDL 2.0 because it has substantial differences from WSDL 1.1:
  • infoset based
  • targetNamespace is a required attribute
  • capability of including and importing documents
  • other types than XSD allowed (DTD ...)
  • additional exchange patterns
  • removal of message constructs
  • no support for operator overloading
  • portTypes renamed to interfaces
  • ports renamed to endpoint
  • support for HTTP PUT/DELETE verbs
  • ...
WSDL 2.0 drawbacks:
  • not well supported by platforms
  • not supported by BPEL
  • WS-I 2.0 (November 2010)

Session Tracking Options

Wether a client will join a session initiated on server side:
  • cookies
  • URL rewriting (the new URL contains a session identifier)
  • SSL session ID

Thursday 15 December 2011

WSDL: SOAP vs. plain HTTP binding

  • SOAP transport bindings: HTTP, SMTP ...
  • SOAP header = metadata, authentication ...
  • SOAP message path processing (header attributes: actor/role, mustUnderstand)
  • SOAP body "document": set of independent body entries (usually one) with encodingStyle
  • SOAP body "rpc": method invocation and method response as "struct" with parameters and return value as "accessors"
  • SOAP encoding (instead of XSD) - DEPRECATED by WS-I Basic profile
  • SOAP fault vs. plain XML fault message with HTTP status code 500
  • SOAP attachment vs. plain WSDL MIME attachment:
    • SwA (SOAP with Attachment): SAAJ (SwA API for Java)
    • MTOM (SOAP Message Transmission Optimization Mechanism) using XOP (XML-binary Optimized Packaging)
    • Abstract model: SOAP 1.2 attachment feature

Note (SwA vs. MTOM):

"MTOM combines the efficiency of SOAP with Attachments, but it does so without having to break the binary data outside of the SOAP message. How can this be? The key is a technology called XOP.

XOP allows binary data to be included as part of the XML Infoset. In fact the XML Infoset becomes a superset of the traditional Infoset known as the XOP Infoset. It allows for the binary data to be stored outside of the XML document, just like in SOAP with Attachments. It uses a special XOP:include element to tell the processor to replace the contents with the referenced binary data, thus encapsulating the logic of discrete storage and retrieval of the binary data. This logic becomes inherent to the XML parser, and allows the SOAP parser to treat the binary data as part of the XML document, with no special retrieval logic. Similarly it allows for a SOAP server to create a SOAP message in a uniform way, no special logic for breaking out that binary data from the SOAP message."

JAX-WS Tutorial & Wrapper/Bare

See:

Wednesday 14 December 2011

JAX-WS WSDL-Java mapping

Java Annotations WSDL Comments
package - definitions "targetNamespace" attribute -
interface or implementation class @WebService @SOAPBinding @BindingType (default SOAP 1.1/HTTP) portType "Service Endpoint Interface" (SEI). Supported SOAP binding styles = document/literal/wrapped (default), document/literal/bare, RPC/literal/(wrapped)
method (synchronous and asynchronous) @WebMethod @WebResult @RequestWrapper @ResponseWrapper operation Only one-way (with @OneWay) and request-response. Neither notification nor solicit-response. Thus, one input message and zero or one output message
request/response wrapper bean, parameter and return value types JAXB annotation types Mapped by JAXB. With "wrapped" parameter mapping style, request/response wrapper beans are generated so JAXB can generate the XSD used in WSDL. With them, developers have complete control over the generated WSDL. Default package is "jaxws"
method parameters @WebParam (override argN names) messages or message parts "wrapper" parameter mapping style tells that the root element of the message, also called "wrapper element" represents the name of the operation. Service parameters are mapped to the children of the root element (like rpc). The "non-wrapper" style does not make this assumption: the entire message is passed as unique service parameter. Out and in/out parameters are mapped to javax.xml.ws.Holder (with public "value" property)
method return value - single output message part, otherwise void With wrapper mapping, the children name must be unique or named "return"
exception @WebFault fault message Mapped fault message is available via getFaultInfo()
class extending Service @WebServiceClient service -
service class getter method @WebEndPoint port Getter returns a proxy thet implements the mapped SEI

Name collision avoidance:
  • "_Type" suffix (class)
  • "_Exception" suffix (Exception class)
  • "_Service" suffix (Service class)
  • "_" prefix (method name)

Tuesday 13 December 2011

WSDL Overview

WSDL structure:
  • types = XSD definitions
  • message = abstract set of message parts of some type
  • operation = set of input/output/fault messages (one-way, request-response, solicit-response or notification)
  • port type = set of operations
  • binding = port type + protocol and concrete format for the abstract messages
  • port = binding + endpoint address
  • service = set of ports
WSDL 1.1 bindings:
  • SOAP (rpc/document operation, literal/encoded message parts, soap header, URI)
  • MIME (content type of a single or mutiple message parts)
  • HTTP (GET/POST binding, operation URI, URL encoded message parts, port URI)
SOAP binding:
  • style (for operations)
    • document: the message parts (usually one) contain documents and are assembled directly under the SOAP body
    • rpc: the message parts contain parameters or return values and are assembled inside a wrapper element for the operation invocation/response under the SOAP body
  • use (for message parts)
    • encoded: message parts are abstract type that require a specific encoding (SOAP encoding or other)
    • literal: message parts are concrete schema definitions

WSDL Example

<wsdl:definitions targetNamespace="http://www.webserviceX.NET/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://www.webserviceX.NET/">
      <s:element name="GetQuote">
        <s:complexType>
          <s:sequence><s:element minOccurs="0" maxOccurs="1" name="symbol" type="s:string" /></s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="GetQuoteResponse">
        <s:complexType>
          <s:sequence><s:element minOccurs="0" maxOccurs="1" name="GetQuoteResult" type="s:string" /></s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="string" nillable="true" type="s:string" />
    </s:schema>
  </wsdl:types>
  <wsdl:message name="GetQuoteSoapIn">
    <wsdl:part name="parameters" element="tns:GetQuote" />
  </wsdl:message>
  <wsdl:message name="GetQuoteSoapOut">
    <wsdl:part name="parameters" element="tns:GetQuoteResponse" />
  </wsdl:message>
  <wsdl:message name="GetQuoteHttpGetIn"></wsdl:message>
  <wsdl:message name="GetQuoteHttpGetOut"></wsdl:message>
  <wsdl:message name="GetQuoteHttpPostIn"></wsdl:message>
  <wsdl:message name="GetQuoteHttpPostOut"></wsdl:message>
  <wsdl:portType name="StockQuoteSoap">
    <wsdl:operation name="GetQuote">
      <wsdl:documentation>Get Stock quote for a company Symbol</wsdl:documentation>
      <wsdl:input message="tns:GetQuoteSoapIn" />
      <wsdl:output message="tns:GetQuoteSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:portType name="StockQuoteHttpGet"></wsdl:portType>
  <wsdl:portType name="StockQuoteHttpPost"></wsdl:portType>
  <wsdl:binding name="StockQuoteSoap" type="tns:StockQuoteSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="GetQuote">
      <soap:operation soapAction="http://www.webserviceX.NET/GetQuote" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="StockQuoteSoap12" type="tns:StockQuoteSoap"></wsdl:binding>
  <wsdl:binding name="StockQuoteHttpGet" type="tns:StockQuoteHttpGet"></wsdl:binding>
  <wsdl:binding name="StockQuoteHttpPost" type="tns:StockQuoteHttpPost"></wsdl:binding>
  <wsdl:service name="StockQuote">
    <wsdl:port name="StockQuoteSoap" binding="tns:StockQuoteSoap">
      <soap:address location="http://www.webservicex.net/stockquote.asmx" />
    </wsdl:port>
    <wsdl:port name="StockQuoteSoap12" binding="tns:StockQuoteSoap12"></wsdl:port>
    <wsdl:port name="StockQuoteHttpGet" binding="tns:StockQuoteHttpGet"></wsdl:port>
    <wsdl:port name="StockQuoteHttpPost" binding="tns:StockQuoteHttpPost"></wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Java Web Services History

VersionJSRReleasedDescription
JAX-WS 2.0224May. 2006
  • JAXB binding
  • WSDL 1.1 (not 2.0)
  • SOAP 1.2 (HTTP, XML Information Set)
  • WS-I Profile 1.1
  • Literal instead of SOAP encoding
  • Asynchronous
  • J2SE 5.0 annotation
  • Security (JSR 183)
JAX-RPC 1.1101Oct. 2003Interoperability (WS-I Profile 1.0)
JAX-RPC 1.0101Jun. 2002Own XML binding

Friday 9 December 2011

Java Application Servers (Glassfish, WebLogic, Geronimo ...)

Server Vendor Current Version Features Comment
Glassfish Glassfish Community 3.0 JEE 6 Full Profile JEE RI
WebLogic Oracle 12c JEE 6 Full Profile Uses Glassfish
Geronimo Apache 3.0 JEE 6 Full Profile Supported by IBM
Websphere IBM 8.5 JEE 6 Full Profile -
 
JBoss Red Hat 7.0 JEE 6 Web Profile -
Resin Caucho 4.0 JEE 6 Web Profile -
JOnAS OW2 Consortium 5.3 JEE 6 Web Profile -
 
Netweaver SAP 7.3 JEE 5 -

Thursday 8 December 2011

Sun Application Server History

ServerFeaturesReleased
Glassfisch (GF) 4.0--
Glassfisch (GF) 3.0Java EE 6, OSGiDec. 2009
Glassfisch (GF) v2Java EE 5Sep. 2007
Glassfisch (GF) v1Java EE 5May. 2006
Sun Java System Application Server (SJSAS) 9.1 (GFv2)Java EE 5/Servlet 2.5Sep. 2007
Sun Java System Application Server (SJSAS) 9.0 (GFv1)Java EE 5/Servlet 2.5May. 2006
Sun Java System Application Server (SJSAS) 8J2EE 1.4/Servlet 2.4Mar. 2004
Sun Java System Application Server (SJSAS) 7J2EE 1.3/Servlet 2.3Oct. 2002
iPlanet/Sun ONE Application Server (iAS) 6.5J2EE 1.2/Servlet 2.2Mar. 2002
iPlanet/Sun ONE Application Server (iAS) 6.0J2EE 1.2/Servlet 2.2May. 2000
NetDynamics Application Server 5.0Servlet 2.1Apr. 1999
NetDynamics Application Server 4.0JDK 1.1Apr. 1998
NetDynamics Application Server 3.1JDK 1.1May. 1997
Netscape Application Server (NAS) 4.0Servlet 2.1Jun. 1999
Netscape Application Server (NAS) 2.1JDK 1.1Mar. 1998
Kiva Application Server 2.0-Dec. 1997
Kiva Application Server 1.5-Nov. 1997

Note: Jcaps 5.1.3:
  • logical host = SJSAS 8
  • emanager = Tomcat 5.0

Java History

Version Released
Java SE 7 Jul. 2011
Java SE 6 Dec. 2006
J2EE 5.0 Sep. 2004
J2SE 1.4 Feb. 2002
J2SE 1.3 May 2000
J2SE 1.2 Dec. 1998
JDK 1.1 Feb. 1997
JDK 1.0 Jan. 1996

Servlet History

API version Released Platform Reference
Servlet 3.0 Dec. 2009 JavaEE 6, JavaSE 6 JSR 315
Servlet 2.5 May 2006 JavaEE 5, JavaSE 5 JSR 154
Servlet 2.4 Nov. 2003 J2EE 1.4, J2SE 1.3 JSR 154
Servlet 2.3 Aug. 2001 J2EE 1.3, J2SE 1.2 JSR 53
Servlet 2.2 Aug. 1999 J2EE 1.2, J2SE 1.2 Part of J2EE
Servlet 2.1 Nov. 1998 Unspecified First official specification
Servlet 2.0 Apr. 1998 JDK 1.1 Java Servlet Development Kit 2.0 (jsdk.jar)
Servlet 1.0 Jun. 1997 - -

Wednesday 7 December 2011

Web Flow Spring MVC Config.

  <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
    <webflow:flow-location id="filterWizzard.csv" path="/WEB-INF/flows/filterWizzard.xml" />
  </webflow:flow-registry>

  <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry" />

  <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
    <property name="flowExecutor" ref="flowExecutor" />
  </bean>

  <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    <property name="flowRegistry" ref="flowRegistry" />
  </bean>

  <!-- JSR 303 validation-->
  <webflow:flow-builder-services id="flowBuilderServices" validator="validator"
    view-factory-creator="mvcViewFactoryCreator" />

  <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />

  <!-- MVC logical view names -->
  <bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
    <property name="viewResolvers" ref="viewResolver" />
  </bean>

Spring Webflow JSR 303 error messages

instead of:
<sf:errors/>

use:
<c:forEach items="${flowRequestContext.messageContext.allMessages}" var="message">
    <div class="err">${message.text}</div>
</c:forEach>

Tuesday 6 December 2011

Spring MVC Form with Session Attribute

@Controller
@RequestMapping("/jcdFilterList.csv")
@SessionAttributes("jcdFilter")
public class JcdFormController
{

  @Autowired
  private JcdDao jcdDao;

  private List<DropdownItem> filterNames;

  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  public JcdFormController()
  {
    logger.info("---------- instantiating ----------");

    filterNames = nameList();
  }

  private static List<DropdownItem> nameList()
  {
    ArrayList<DropdownItem> result = new ArrayList<DropdownItem>();

    // Assign labels
    [...]

    return result;
  }

  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  // add reference data to model
  @ModelAttribute("filterNames")
  public List<DropdownItem> getFilterNames()
  {
    return filterNames;
  }

  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  @RequestMapping(method = RequestMethod.GET)
  public String showForm(Map<String, Object> model)
  {
    logger.fine("showForm");
    if (model.get("jcdFilter") == null)
    {
      model.put("jcdFilter", new Filter());
    }
    return "filterForm";
  }

  @RequestMapping(method = RequestMethod.POST)
  public String processForm(Map<String, Object> model, @Valid @ModelAttribute("jcdFilter") Filter filter, BindingResult binding) throws JcapsDocException
  {
    logger.fine("processForm");
    logger.fine(filter.toString());
    if (binding.hasErrors())
    {
      return "filterForm";
    }
    else
    {
      model.put(JcdListController.JCD_LIST_KEY, jcdDao.get(filter));
      return "csvList";
    }
  }

Spring MVC Form Processing

See http://levelup.lishman.com/spring/form-processing/controller.php

Thursday 1 December 2011

Spring properties, XML and annotation

  <util:properties id="config" location="classpath:config.properties" />

---

  <bean id="directoryDao" class="bla.bla.Bla">
    <constructor-arg>
      <value>#{config['jcdListPath']}</value>
    </constructor-arg>
  </bean>

---

  @Value("#{config['javadocTreeUrl']}")
  private String javadocTreeUrl;

  @RequestMapping("/buildJavadoc")
  public String buildJavadoc()  {
    return "redirect:" + javadocTreeUrl;
  }

Thursday 24 November 2011

AOP Timer

    <aop:aspectj-autoproxy />
    <bean id="timer" class="AopTimer" />

----------




@Aspect
public class AopTimer
{
  private static final Logger logger = Logger.getLogger(AopTimer.class.getName());

  public AopTimer()
  {
    logger.info("---------- instantiating ----------");
  }

  @Around("@annotation(com.helpdeskSos.aop.TimeIt)")
  public Object time(ProceedingJoinPoint jp) throws Throwable
  {
    long start = new Date().getTime();
    try
    {
      return jp.proceed();
    }
    finally
    {
      long end = new Date().getTime();
      String method = jp.getTarget().getClass().getSimpleName() + "." + jp.getSignature().getName();
      logger.info("ellapsed time in " + method + ": " + (end - start) + " (ms)");
    }
  }
}

----------




@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface TimeIt
{

}


----------

  @TimeIt
  public void sendMail(Incident incident)

Thursday 17 November 2011

Scroller following Focus

private function scrollToFocus(e:FocusEvent):void
{
                if (!SCROLLER.verticalScrollBar.visible) return;
               
                var focus:DisplayObject = e.currentTarget as DisplayObject;
               
                var focusTop:Number = 0;
                var focusAncester:DisplayObject = focus;
                while(focusAncester != SCROLLER)
                {
                    focusTop += focusAncester.y;
                    focusAncester = focusAncester.parent;
                }
               

                var focusBottom:Number = focusTop + focus.height;

                var windowTop:Number = FIELDS.verticalScrollPosition;
                var windowBottom:Number = windowTop + FIELDS.height;
               
                // No scroll needed
                if (windowTop <= focusTop && focusBottom < windowBottom) return;
               
                // 10 pixels padding
                FIELDS.verticalScrollPosition = focusTop - 10;
}

----------

<s:Scroller id="SCROLLER>
   <s:VGroup id="FIELDS">
      <s:Form id="FORM">
                               
         <s:FormItem width="100%" label="Nachname" required="true">
            <s:TextInput id="NAME" width="50%" focusIn="scrollToFocus(event)"/>
         </s:FormItem>

...

Monday 14 November 2011

Install Tomcat 5.5 and 6.0 as Windows Service

sc config Tomcat5 DisplayName= "Apache Tomcat 5.5" (mind the blank after "=")

Modify ports in server.xml:
<Server port="8095" shutdown="SHUTDOWN">
<Connector port="8090" protocol="HTTP/1.1"connectionTimeout="20000" redirectPort="8443" />
<Connector port="8099" protocol="AJP/1.3" redirectPort="8443" />

Monday 17 October 2011

Trace all events of a component

override public function dispatchEvent(event:Event):Boolean
{
  trace(event.type);
  return super.dispatchEvent(event);
}

Wednesday 12 October 2011

Remove items from Flex ArrayCollection

var alerts:ArrayCollection = new ArrayCollection();

for (var i:int = alerts.length; i > 0; i--)
{
   var alert:Alert = alerts.getItemAt(i-1) as Alert;
   if (alert.parentName == parentName)
   {
      alerts.removeItemAt(i-1);
   }
}

Note: alerts.length is initialized once and thus does not vary, on the contrary of:

for (var i:int =0; i < alerts.length; i++)

Monday 10 October 2011

Friday 7 October 2011

Flex Client - Jcaps JMS messaging-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service" class="flex.messaging.services.MessageService">

    <adapters>
            <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter" />
    </adapters>

    <default-channels>
        <channel ref="my-polling-amf" />
    </default-channels>

    <destination id="jcapsBefund">
        <adapter ref="jms" />
        <properties>
            <jms>
                <destination-type>Topic</destination-type>
                <message-type>javax.jms.TextMessage</message-type>
                <connection-factory>connectionfactories/topicconnectionfactory</connection-factory>
                <destination-jndi-name>topics/tOibbefundFromSpacelab</destination-jndi-name>
                <delivery-mode>NON_PERSISTENT</delivery-mode>
                <message-priority>DEFAULT_PRIORITY</message-priority>
                <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
                <initial-context-environment>
                    <property>
                        <name>Context.INITIAL_CONTEXT_FACTORY</name>
                        <value>com.stc.jms.jndispi.InitialContextFactory</value>
                    </property>
                    <property>
                        <name>Context.PROVIDER_URL</name>
                        <value>stcms://blabla.uhbs.ch:12345</value>
                    </property>
                    <property>
                        <name>Context.SECURITY_PRINCIPAL</name>
                        <value>Hello</value>
                    </property>
                    <property>
                        <name>Context.SECURITY_CREDENTIALS</name>
                        <value>World</value>
                    </property>
                </initial-context-environment>
            </jms>
        </properties>
    </destination>
</service>

Thursday 6 October 2011

Flex Binding Example

    [Bindable]
    public class Configuration extends EventDispatcher
    {
        public static const URL_CHANGED:String = "urlChanged";
       
        private var _host:String;
        private var _port:String;
        private var _context:String;
       
        public function Configuration(host:String, port:String, context:String)
        {
            this.host = host;
            this.port = port;
            this.context = context;
        }
       
        public function get host():String
        {
            return _host;
        }
       
        public function set host(value:String):void
        {
            _host = value;
            dispatchEvent(new Event(URL_CHANGED));
        }
       
        public function get port():String
        {
            return _port;
        }
       
        public function set port(value:String):void
        {
            _port = value;
            dispatchEvent(new Event(URL_CHANGED));
        }
       
        public function get context():String
        {
            return _context;
        }
       
        public function set context(value:String):void
        {
            _context = value;
            dispatchEvent(new Event(URL_CHANGED));
        }

        // DO NOT USE the URL_CHANGED constant

        [Bindable(event="urlChanged")]
        public function get url():String
        {
            return "http://" + host + ":" + port + "/" + context + "/messagebroker/amfpolling";
        }

Monday 19 September 2011

Tomcat LDAP authentication

1. allow SSL connections, adding the LDAP server root certificate to the cacerts
   file of the Tomcat JRE. It can be found in your $JAVA_HOME/lib/security directory.
   Use the java keytool command to add the certs:
  
   List the existing certificates:
   keytool -list -v -keystore cacert
  
   Import certificate:
   keytool -importcert -alias HELLO -file <path>/trustedrootcert.cer -keystore <path>/lib/security/cacerts
   Password is: changeit 

2. verify the configuration in <CATALINA_BASE>/conf/Catalina/localhost/<webapp>.xml:

    <Realm className="org.apache.catalina.realm.JNDIRealm"

        connectionURL="ldaps://ldap.company.org:636"
        connectionName="cn=user,ou=serviceusers,ou=services,o=ORG"
        connectionPassword="pwd"
       
        userBase="o=ORG"
        userSubtree="true"
        userSearch="(cn={0})"

        roleBase="ou=Functions,ou=GROUPS,o=ORG"
        roleName="cn"
        roleSearch="(member={0})"
    />

3. verify the configuration in web.xml:

    <security-constraint>
        <display-name>LDAP security constraint</display-name>
        <web-resource-collection>
            <web-resource-name>Protected Area</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>MyRequiredGroup</role-name>
        </auth-constraint>
    </security-constraint>

    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>Tomcat auth</realm-name>
    </login-config>

    <security-role>
        <role-name>MyRequiredGroup</role-name>
    </security-role>

Apache LDAP Authentication

<IfModule !mod_auth_ldap.c>
  LoadModule auth_ldap_module modules/auth_ldap.so
</IfModule>

<IfModule mod_auth_ldap.c>
  LDAPSharedCacheFile logs/ldap_cache
</IfModule>

<Directory /caps/wwwstatus/>

        AuthName "My Restricted Area"
        AuthType Basic

        # AuthLDAPURL should point to your ldap server
        AuthLDAPURL ldap://localhost:389/o=ORG?cn

        # LDAP Login
        AuthLDAPBindDN cn=auser,ou=serviceusers,ou=services,o=ORG
        AuthLDAPBindPassword pwd

        # AuthLDAPGroupAttribute memberUid
        AuthLDAPGroupAttributeIsDN on
        require group cn=GROUP,ou=GROUPS,o=ORG
</Directory>

<Directory /caps/wwwstatus/data/>
        # Allow access to Javadoc without authentication - needed to link when generating javadoc
        Satisfy Any
        Allow from all
</Directory>

Thursday 15 September 2011

Remove GIF background with Photoshop

  • Convert the GIF file from indexed to RGB: Image > Mode > RGB
  • Remove the background with the magic wand tool, clicking on the background
  • Invert your selection: Select > invert
  • In the Layer window double click your Background Layer. It will convert it in a layer (the name will not be in italics anymore)
  • At the bottom of the Layer window there is an icon for creating a new mask. Click on it and your selection should be converted into a mask, letting the background transparent for your logo. The transparent background in photoshop is represented with little grey squares
  • Save it as a PSD file
  • Save it as GIF file

Wednesday 14 September 2011

Force logging programmatically

Logger.getLogger("some.package.and.class").setLevel(Level.FINEST);
Logger.getLogger("").getHandlers()[0].setLevel(Level.ALL);

Friday 9 September 2011

Flex Builder - WTP Project Integration

+ Install Flash Player Debug (Firefox, IE and SA)
+ Copy ROOT
+ Add manager.xml:

<Context docBase="${catalina.home}/webapps/manager" antiResourceLocking="false" privileged="true"/>

+ Configure logging (instead of JDK)




+ Create a Java project and Add Flex project type or edit ".flexProperties":
   serverContextRoot, serverRoot and serverRootURL
   and save, refresh and recompile the project

Thursday 8 September 2011

Tomcat in Eclipse


Default server settings
+ check "Publish module contexts to separate XML file"
+ copy ROOT to wtpwebapps

Friday 26 August 2011

Flash Version Finder

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
  
    <fx:Script>
      
        <![CDATA[
          
            private function doTrace(event:MouseEvent):void
            {
                trace("bla bla bla");
              
                if (Capabilities.isDebugger) {
                    OUT.text = "Debugger Flash Player";
                } else {
                    OUT.text = "Normal Flash Player";
                }
            }
          
        ]]>
      
    </fx:Script>
  
    <fx:Declarations/>
   
    <s:Panel id="PNL" x="0" y="0" width="100%" height="100%" title="Testpanel">
        <s:Button id="BTN" x="50" y="50" label="Clickme" click="doTrace(event)"/>
        <s:Label id="OUT" x="50" y="116" text="-"/>
    </s:Panel>
</s:Application>

==========
Ergebnis:

Friday 19 August 2011

Internet Explorer Password Registry Keys

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main =>
"FormSuggest Passwords" 
"FormSuggest PW Ask"

Friday 15 July 2011

Wednesday 1 June 2011

Java Logging / java.util.logging / logging.properties

See here.

NB: the default eclipse logger has to be configured using java.util.logging.config.file and java.util.logging.manager in the Server's run configuration. Otherwise, it uses the JDK's logging.properties file in $JAVA_HOME/jre/lib:

-Djava.util.logging.config.file="C:\Programme\Apache\Tomcat\Tomcat-6.0.16\conf\logging.properties"
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

Tuesday 24 May 2011

Flash Debugger flashlog.txt

Needs following in %HOMEDRIVE%%HOMEPATH%\mm.cfg (per default C:\mm.cfg).

Target: C:\Dokumente und Einstellungen\<User>\Anwendungsdaten\Macromedia\Flash Player\Logs\falshlog.txt

See also here.



# Enables the logging of error messages
ErrorReportingEnable=1

# Enables trace logging
TraceOutputFileEnable=1

# Lets you save the contents of the log file
PolicyFileLogAppend=1

# Sets the number of warnings to log before stopping
MaxWarnings=0

# ---------- Undocumented ----------

# Enables buffered trace
TraceOutputBuffered=1

# Traces every single call to any function that is being called in the SWF at runtime
AS3Trace=0

# Detailed information about SWF bytecode structure and runtime parsing of the bytecode
AS3Verbose=0

Monday 23 May 2011

tail -f for Windows

See the Windows Server 2003 Resource Kit Tools!

Friday 1 April 2011

Bash For Loop

for num in $(seq 1 10);
  do echo "num-$num";
done

Friday 11 March 2011

Wichtige Jcaps Fixes

  • Emanager stopserver.sh - KB 1025330.1
  • Emanager/Domain "access denied" - HF 2177794
  • Emanager Alerts Refresher - HF 7003076
  • Commandline codegen HL7 und BAPI - com.stc.otd.ud1runimpl.jar in compile\lib\ext\

Thursday 10 March 2011

Jcaps Migration

  • für Oracle ist die Zukunft von Jcaps die Oracle SOA Suite
  • Support Lifetime, see here: normaler Support bis Ende 2013, extended Support bis Ende 2016
  • Lizenz für Jcaps ist auch Lizenz für die SOA Suite
  • Als nächstes kommt Jcaps 6.3 und Oracle SOA Suite "Healthcare Fastpath 1.0/2.0"
  • In der SOA Suite wird nicht mehr mit Netbeans sondern mit JDeveloper entwickelt
  • Empfehlunbg von Oracle: bis "Fastpath 1.0" warten
  • JCD werden migriert

Wednesday 9 March 2011

SOAP, WSDL, Web Services

Oracle Database

Hsqldb

Crystal Reports

SAP

Subversion, SVN

JavaScript

MD5, Base 64, Epoch, Character Sets Online

Wo ist stcms.exe konfiguriert (ports, memory limits ...)?

In stcms.default.properties.

Warum braucht meine Domaine so viel mehr RAM als in Xmx definiert?

Die gebrauchte Memory in Java besteht aus heap und non-heap. Im non-heap Bereich gibt es vor allem:

- permanent space (MaxPermSize)

- thread stacks: für jeden Thread Xss - per Default auf HP-UX 64 bits 1 MB (siehe Punkt 21 unten)

Es ergibt sich also: Memory = Xmx + MaxPermSize + Anzahl Threads x Xss

Hängender Thread bei jcdPutToFtpLargeFile

Der Service läuft, verarbeitet aber keine weiteren Jobs. Der Service lässt sich nicht stoppen. Keine Hinweise im server.log.

Lösung: Environment "Connection Pool Settings" anpassen: "Steady pool size" 0, "Max Idle Timeout in Seconds" 1. "Maximum pool size" kann auf default 10 bleiben.

Where does JCAPS store the Batch sequence number?

By default in <domain>\applicationdata\hostadapter\***\*.state. This value can be overridden in the Environment (State Persistence Base Location, by default blank).

Warum arbeitet Emanager die ganze Zeit (high CPU in top oder ähnliches)?

Es kann mehrere Gründe haben.

Ein Grund kann das Archivieren von vielen Alerts sein.

Ein anderer Grund kann ständige Refreshs sein. "Disable Browser Auto Refresh" hilft bei Alerts nicht: auch wenn enabled wird refresht, und zwar anhand des "Browser Refresh Rates" (das sieht man im Emanager log deutlich).

Dieser Parameter sollte daher hoch gesetzt bzw. hoch gelassen werden, z.B. 3600 (1 Std.). Sonst werden die Alerts immer wieder angefragt, was zur Überbelastung führen kann.

Wo sind die JCAPS Alerts?

Die Alerts sind in einer In-Prozess HSQL DB Version 1.8.0 gespeichert. Der Inhalt der Alert Datenbank kann anhand des MAX_AGE_OF_EVENTS Archiver Parameter konfiguriert werden (die anderen Parameter beeinflussen nur, wann der Archive Prozess läuft).

Notiz: MAX_AGE_OF_EVENTS funktioniert nur wenn GROUP_MAX_COUNT = 0.

Wie kann ich JMX für mein Domain aktivieren?

Folgende Parameter setzen und restarten:
  • -Dcom.sun.management.jmxremote.authenticate=false
  • -Dcom.sun.management.jmxremote.ssl=false
  • -Dcom.sun.management.jmxremote.port=<JMX Port>

JCO Shared Libraries unter HP-UX

Die nativen Shared Libraries, die JCO benötigt werden unter HP-UX mit der Variable SHLIB_PATH referenziert.

Wie kann man die Emanager Event Respository Db schneller machen?

Wir haben folgendes auf K geändert, um dis HSQL DB schneller zu machern:

- in EventRepositoryDb.script:

CREATE INDEX MSG_CODE_ARGS_IDX ON MSG_CODE_ARGS(ID)
CREATE INDEX NOTIFICATION_EVENT_IDX ON NOTIFICATION_EVENT(ID)

- in EventRepositoryDb.properties:

hsqldb.cache_size_scale=10 (statt 8)
hsqldb.cache_scale=18 (statt 14)

Vor allem das erste schien SEHR effektiv zu sein: der Prozess, der seit heute morgen unterwegs war ist innerhalb einiger Sekunden fertig gewesen. Somit hoffe ich, dass der Archiver schneller als unsere Alertproduktion sein wird.

Why is the "Total message retained" of a JMS Server different from the sum of the message queues/topics?

The actual meaning of "Total messages retained" is the "how many 'DataIMessages' the stcms server is currently using".

A "DataIMessage" includes all the different types of message that the stcms server uses. Thus includes JMS messages (all destinations), and also "Control" messages. You have probably seen topics like STCMS.Control or STCTemporaryTopic.1051196711431.1051192422022.1, which can be used internally by stcms for Control messages.

Every time the server creates a DataIMessage it increments the counter. When it destroys a message it decrements the counter. It is this count of DataIMessage which is reported as "Total messages retained". A DataIMessage might not get destroyed until the stcms performs "cleanup", which means the count may also include JMS messages which have been consumed.

After all user JMS messages have been consumed, and the stcms server has performed cleanup, the value of "Total messages retained" will be close to 0, but never actually 0 (because to obtain the server status, a message is sent to the Control Topic which the server will treat as a DataIMessage).

Wie kann ich Javadoc in eDesigner erweitern?

It’s not possible to use Javadoc as html files in eDesigner. The javadoc only works when the source code (with javadoc) is available. Thus, to extend Javadoc, you need to integrate the source code in a library (jar) and copy the source code in the following directory of edesigner:

edesigner\jdk\src

The source code of the Java virtual machine is available and certainly only used for the javadoc. If for example you add the Avintis framework, the javadoc will be available. Because the eways sources aren't available, it's not possible to have the javadoc of the connectors in eDesigner.

How to enable the JVM SNMP Agent in a domain, without getting start/stop errors

  1. copy launcher.xml in logicalhost\is\lib to logicalhost\is\domains\<domain name>\config
  2. add the jvm snmp agent arguments as <sysproperty> elements under <launch>. e.g.:

    <sysproperty key="com.sun.management.snmp.interface" value="0.0.0.0" />
    <sysproperty key="com.sun.management.snmp.port" value="8888" />
  3. append the following string after 'LauncherBootstrap' in logicalhost\is\domains\<domain name>\bin\startserv:

    -launchfile "$INSTANCE_ROOT/config/launcher.xml"
Adding the SNMP parameters in domain.xml (as JVM option) produces the error "CLI157 Could not stop the domain".

This allows e.g. to monitor the JVM heapsize via Spectrum.

Wieviele Instanzen meiner JCD gibt es denn?

See here:

"When you create a JCD that implements an existing web service (ie a JCD that is started by a connector), eDesigner will create a message driven bean that is triggered by the connector and a stateless session bean that will be called from the message driven bean. This stateless session bean will call your JCD web service method, the receive or the start method.

Because your JCD is hosted in a stateless session bean it will receive all the benefits of the J2EE thread and instance management. If there are multiple JMS messages to process, the application server can create multiple instances of the stateless session bean that hosts your JCd and thereby multiple instances of your JCD class will be created. If these are no longer needed, the application server can destroy them.

...

When your JCD's are started by a JMS message (this is when your JCD's implement the JMS receive web service), you can configure in the connectivity map how many instances of your JCD can be started concurrently by the application server. When double clicking the configuration block on the JMS inbound connection you can specify two options:

  • Connection Consumer or Serial mode: multiple instances can be started when multiple messages are available or not
  • Server session pool size: how many instances can be created.
If your message is implementing a new web service instead of an existing web service, it will still be hosted by a stateless session bean. However, because it will not be triggered by a connector, no message driven bean will be generated.

...

If you Java collaboration is exposed as an external callable web service, the stateless session bean will be called by the servlet, if your collaboration is called from en eInsight business process, the stateless session bean will be called by a message driven bean that is triggered from the eInsight BPEL engine."

Daher können 1 oder mehrere Instanzen einer JCD existieren, sogar 0 wenn die Aktivität sehr niderig ist.

Welcher Prozess braucht diese Socket?

lsof -i TCP

Und welche Netzwerkkarten gibt es?

lanscan

HTTPS access denied

wenn folgender Fehler beim Zugriff auf einen HTTPS-Server auftritt (Ausschnitt):

Failed to add the JSSE provider
com.sun.net.ssl.internal.ssl.Provider; Exception :
java.lang.Exception: Failed to add provider
com.sun.net.ssl.internal.ssl.Provider; Exception :
java.security.AccessControlException: access denied
(java.security.SecurityPermission insertProvider.SunJSSE)
at
com.stc.connector.httpadapter.eway.HTTPEwayConnecti on.initialize

liegt das daran dass die Domain das nicht zulässt. Dies kann man ändern indem man die server.policy ergänzt:

/caps/JCAPS513/logicalhost/is/domains/<DOMAIN>/config/server.policy


// ICAN HTTP eWay
permission java.security.SecurityPermission "insertProvider.SunJSSE";

Dies ist eine Domain - spezifische Einstellung.

Wie kann man JCAPS mit einem neuen Repository verbinden?

Als erstes muss man die neue Repository URL in folgenden Dateien eintragen:
runed.bat
repositoryadmin.bat

Dann muss man folgendes Kommando ausführen, um die URL des Update Centers zu ändern:
runed.bat <host> <port> <repo>
Dies sollte mit folgendem Output quittiert werden:

BUILD SUCCESSFUL
Total time: 0 seconds
Starting Enterprise Designer...

Dann muss die URL im Login Screen geändert werden (einmal).

DNS-Switch

Bei DNS-Switch bekommt ein Hostname eine neue IP Adresse. JCAPS speichert aber die IP Adresse, und scheitert wenn Daten übermittelt werden müssen. Das JCAPS Domain muss neu gestartet werden, um das Problem zu lösen.

Das Problem betrifft sicherlich die Oracle Verbindungen vom Oracle eWay, und vielleicht andere Bereiche:
HL7, TCPIP ...

Dies muss bei "DNS Switch" mit Oracle Datenbankverbingungen geplant werden.

Dies scheint ein allgemeins Java Problem zu sein, wie hier erklärt. Möglicherweise kann man das Probelm beim Setzen von networkaddress.cache.ttl lösen.

HP-UX Cluster

K und P sind auf HP-UX Cluster installiert, die so aufgesetzt sind:
K: ccakx02 = scakx01 + scakx02
P: ccapx02 = scapx01 + scapx02

Beide Clusternodes, z.B. scakx01 und scakx02 sind gestartet aber JCAPS läuft auf nur ein Node.
Auf diesem Node ist das Shared-Verzeichnis /caps montiert. Das / Verzeichnis ist dagegen Nodespezifisch.

Bei "Nodeswitch" wird JCAPS mittels Skripte in /caps/script gestoppt (stopCaps.sh) und gestartet (startCaps.sh). Das Ergebnis des Skriptes kann man so verfolgen:

tail -f /etc/cmcluster/capsP/capsP.cntl.log

Die Clusteradresse (z.B. ccakx02) zeigt dann auf dem neuen Host (z.B. scakx02 statt scakx01).

Beim Nodeswitch gab es ein Problem mit Spectrum, das ein Clusternode aber nicht das andere abgefragt hat.
Beim Switchen war dann die Load in Emanager auf dem neuen Host viel höher.
Dies liess sich mit einer Portänderung beim SNMP Agent lösen.