How can I implements Message Inspectors? - java

I want to build a soap Client .NET to contact Java web service. The problem is in the response because there is no compatibility from Java and .NET for the signature.
So I want to disable the validation response from .NET, for this, I have find this articles on MSDN
https://msdn.microsoft.com/en-us/library/aa717047.aspx
I can read that it possibile to insert a method that intercept the response and I can bypass the check. But I'm not able to do this.
I have write import in my project these class:
SchemaValidationBehavior
SchemaValidationBehaviorExtensionElement
SchemaValidationMessageInspector
This is my app.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="MyNewService">
<security defaultAlgorithmSuite="Basic128" authenticationMode="MutualCertificate" requireDerivedKeys="false" securityHeaderLayout="Lax" includeTimestamp="true" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" requireSignatureConfirmation="false">
<localClientSettings detectReplays="true"/>
<localServiceSettings detectReplays="true"/>
</security>
<textMessageEncoding messageVersion="Soap11WSAddressing10"/>
<httpsTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://edottotest.sanita.regione.rsr.rupar.puglia.it/nsisr/PianoAssistenzialeResidenzialeService" binding="customBinding" bindingConfiguration="MyNewService" contract="PianoAssistenzialeResidenzialeService.PianoAssistenzialeResidenziale" name="PianoAssistenzialeResidenzialePort" >
<identity>
<dns value="HEALTHNETBR"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
I think the problem is on this file.

Related

This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. c#

Maybe this question already has but I think there is a different situation.
I configure all required things from the web config file and install certificates.
I consume java web service in ASP.NET WEB API.
SOAP service was configured mutual authentication. (Two-way SSL)
I have 2 Keystore files. (client.jks and truststore.jks)
My full error: This could be due to the fact that the server certificate is
not configured properly with HTTP.SYS in the HTTPS case.
This could also be caused by a mismatch of the security binding between
the client and the server.'
WebConfig:
<customBinding>
<binding name="MyBinding">
<textMessageEncoding messageVersion="Soap11"/>
<security authenticationMode="MutualCertificate" enableUnsecuredResponse="true" allowSerializedSigningTokenOnReply="true"
messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
includeTimestamp="false">
</security>
<httpsTransport />
</binding>
</customBinding>
<endpoint behaviorConfiguration="ClientCredentialsBehavior" address="https://abc.bank.dm:9193/Money/Money" binding="customBinding" bindingConfiguration="MyBinding" contract="Ref.Port" name="Port">
<identity>
<dns value="test"/>
</identity>
</endpoint>
<behaviors>
<endpointBehaviors>
<behavior name="ClientCredentialsBehavior">
<clientCredentials>
<clientCertificate findValue="2d73n94087857dndyr874ydr"
storeLocation="CurrentUser"
storeName="My"
x509FindType="FindByThumbprint" />
<serviceCertificate>
<defaultCertificate findValue="d346n32d48938w43d943095d"
storeLocation="CurrentUser"
storeName="TrustedPeople"
x509FindType="FindByThumbprint" />
<authentication certificateValidationMode="None" revocationMode="NoCheck"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
Try to specify the same protocol on the client and server. Add the following code in the client:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
Here is the reference: TLS 1.2

Consuming WCF service in Java does not generate an interface

We have a pretty big WCF service that we use for quite some time, but up until now we've been connecting to it only via c#. Now we have a need to connect to it from Java.
I found out quickly that if I use Eclipse and go to new/other/Web Service Client I can put the WSDL link there to auto generate the code.
Doing that straight away did not produce much though. I obtained two files, one of which had empty body.
This is my first issue with this auto generation tool - it creates something, but I don't see any log of what it succeeded and what failed in creating.
I searched and found out that i had to change the bindings to basicHttpBinding, and make sure that httpGetEnabled is set to "true". After this change, auto generation in Java produces a lot of code, i get the data contract schemas and so on. And I get 4 files under the 'org.tempuri' namespace:
BasicHttpBinding_IMyServiceStub.java
IMyServiceProxy.java
MyService.java
MyServiceLocator.java
However looking at some tutorials, it seems I should get a fifth one, IMyService.java - which I did not get. And, I do have errors in the generated code pointing out that indeed IMyService cannot be resolved, as its being used in a few places, but its definition was not auto-generated.
Since I have no logs of what has failed during auto generation, I'm kind of lost what to look for as a culprit.
Does anyone have any experience on either:
a) locating logs for auto generation that would tell me what went
wrong
b) directly know what causes the Interface class not to be generated?
I'm suspecting i have to change something more in webconfig file on the server. A second guess is that perhaps we use some c# construct not recognised by java...or something.
Anyway, completly lost here, as there is no feedback of what went wrong.
Here is a webconfig file from the IIS server.
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="XXX" connectionString="XXX" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation targetFramework="4.0"/>
<customErrors mode="Off"/>
<httpRuntime executionTimeout="5400" requestValidationMode="2.0"/>
<identity impersonate="false"/>
</system.web>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="bindingNetTcp" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00">
<binaryMessageEncoding maxSessionSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binaryMessageEncoding>
<tcpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</binding>
<binding name="bindingHttps" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00">
<binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647" maxSessionSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binaryMessageEncoding>
<httpsTransport manualAddressing="false" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" allowCookies="true" authenticationScheme="Anonymous" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous" realm="" transferMode="StreamedResponse" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true"/>
</binding>
<binding name="bindingHttp" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00">
<binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647" maxSessionSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binaryMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" allowCookies="true" authenticationScheme="Anonymous" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous" realm="" transferMode="StreamedResponse" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true"/>
</binding>
</customBinding>
<netTcpBinding>
<binding name="NetTcpBinding_IGodService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Transport">
<transport clientCredentialType="Certificate" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
<binding name="NetTcpBinding_IGodService1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Transport">
<transport clientCredentialType="Certificate" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
<binding name="CustomBinding_IDQMServer">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="XXX.XXX" behaviorConfiguration="XXXBehavior">
<host>
<baseAddresses>
<add baseAddress="net.tcp://example.com:4502/xxx/xxx/"/>
<add baseAddress="http://example.com/xxx/xxx/"/>
</baseAddresses>
</host>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint address="" binding="customBinding" bindingConfiguration="bindingHttps" contract="xxx.Ixxx"/>
<endpoint address="" binding="basicHttpBinding" contract="xxx.Ixxx"/>
<endpoint address="" binding="customBinding" bindingConfiguration="bindingNetTcp" contract="xxx.Ixxx"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="xxxBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceThrottling maxConcurrentCalls="2500" maxConcurrentInstances="2147483647" maxConcurrentSessions="2147483647"/>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SrvBehavior">
<clientCredentials>
<clientCertificate findValue="xxx" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<defaultDocument>
<files>
<add value="xxx.svc"/>
</files>
</defaultDocument>
</system.webServer>
</configuration>
Please note that im using basicHttpBinding there, previously it was "bindingHttp" like the https one, but it didnt work at all.
EDIT: As pointed out in the comment section, we're using Lists in the service quite a lot, an example of the c# wcf interface:
public class ListResults<T>//our own custom return class
{
public List<T> Result { get; set; }
public long? ID { get; set; }
public int? Error { get; set; }
}
[SecurityOperationBehavior]
[OperationContract]
ListResults<SomeDataType> SomeListFunction(string param1, long? param2, bool? param3);

Workflow Content handling

I am using Liferay 6.1.1 CE.
I've created a multilevel kaleo workflow (i.e. with two levels of approvals), by writing a definition in a xml file (leaveapproval.xml) and loading it to the server. It works fine as I have tested this workflow in Blogs.
So now, I wants to submit the content of the workflow to a web service after completing the second level approval.
How can i handle the content of the workflow?
Is it possible?
<?xml version="1.0"?>
<workflow-definition
xmlns="urn:liferay.com:liferay-workflow_6.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:liferay.com:liferay-workflow_6.1.0 http://www.liferay.com/dtd/liferay-workflow-definition_6_1_0.xsd">
<name>LEAVE IN ACTION USER ACTION</name>
<description>A sample multilevel approver can approve a workflow content.</description>
<version>1</version>
<state>
<name>created</name>
<metadata>
<![CDATA[
{"xy":[36,51]}
]]>
</metadata>
<initial>true</initial>
<transitions>
<transition>
<name>review</name>
<target>review</target>
<default>true</default>
</transition>
</transitions>
</state>
<task>
<name>review</name>
<metadata>
<![CDATA[
{"xy":[168,36]}
]]>
</metadata>
<actions>
<notification>
<name>Review Notification</name>
<template>You have a new submission waiting for review in the workflow.</template>
<template-language>text</template-language>
<notification-type>email</notification-type>
<execution-type>onAssignment</execution-type>
</notification>
<notification>
<name>Review Completion Notification</name>
<template>
Your submission has been reviewed and the reviewer has applied the following ${taskComments}.</template>
<template-language>freemarker</template-language>
<notification-type>email</notification-type>
<recipients>
<user />
</recipients>
<execution-type>onExit</execution-type>
</notification>
</actions>
<assignments>
<roles>
<role>
<role-type>regular</role-type>
<name>Portal Head</name>
</role>
<role>
<role-type>regular</role-type>
<name>Portal Content Reviewer</name>
</role>
</roles>
</assignments>
<transitions>
<transition>
<name>approve</name>
<target>recommended</target>
</transition>
<transition>
<name>reject</name>
<target>update</target>
<default>false</default>
</transition>
</transitions>
</task>
<task>
<name>recommended</name>
<metadata>
<![CDATA[{"xy":[168,36]}]]>
</metadata>
<actions>
<notification>
<name>Review Notification</name>
<template>You have a new submission waiting for your review in the workflow.</template>
<template-language>text</template-language>
<notification-type>email</notification-type>
<execution-type>onAssignment</execution-type>
</notification>
<notification>
<name>Review Completion Notification</name>
<template>
Your submission has been reviewed and the reviewer has applied the following ${taskComments}.</template>
<template-language>freemarker</template-language>
<notification-type>email</notification-type>
<recipients>
<user />
</recipients>
<execution-type>onExit</execution-type>
</notification>
</actions>
<assignments>
<user>
<user-id>13379</user-id>
</user>
</assignments>
<transitions>
<transition>
<name>approve</name>
<target>approved</target>
</transition>
<transition>
<name>reject</name>
<target>update</target>
<default>false</default>
</transition>
</transitions>
</task>
<task>
<name>update</name>
<metadata>
<![CDATA[
{"transitions":{"resubmit":{"bendpoints":[[303,140]]}},"xy":[328,199]}
]]>
</metadata>
<actions>
<action>
<name>reject</name>
<script>
<![CDATA[
Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(
Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("denied"),
workflowContext);
Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(
Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("pending"),
workflowContext);
]]>
</script>
<script-language>javascript</script-language>
<execution-type>onAssignment</execution-type>
</action>
<notification>
<name>Creator Modification Notification</name>
<template>Your submission was rejected by a reviewer, please modify and resubmit.</template>
<template-language>text</template-language>
<notification-type>email</notification-type>
<execution-type>onAssignment</execution-type>
</notification>
</actions>
<assignments>
<user />
</assignments>
<transitions>
<transition>
<name>resubmit</name>
<target>review</target>
</transition>
</transitions>
</task>
<state>
<name>approved</name>
<metadata>
<![CDATA[
{"xy":[380,51]}
]]>
</metadata>
<actions>
<action>
<name>approve</name>
<script>
<![CDATA[Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus (Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("approved"), workflowContext);]]>
</script>
<script-language>javascript</script-language>
<execution-type>onEntry</execution-type>
</action>
</actions>
</state>
</workflow-definition>
Help me..
For running anything programmatically on a certain workflow step, you generally just need a <script> tag, just like you're doing to update the statuses.
So, in your approved <state>, you'd probably want to add another <action> tag, this one to handle the web service call (and let the other action remain the way it is).
The language you'd use for the script will depend on what you're comfortable with. I'd use groovy, since it handles plain java code pretty well, and that's what I know.
Here's what it might look like (only including that last <state> tag):
<state>
<name>approved</name>
<metadata>
<![CDATA[
{"xy":[380,51]}
]]>
</metadata>
<actions>
<action>
<name>approve</name>
<script>
<![CDATA[
Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(
Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("approved"),
workflowContext);
]]>
</script>
<script-language>javascript</script-language>
<execution-type>onEntry</execution-type>
</action>
<action>
<name>submit-web-service</name>
<script>
<![CDATA[
import java.io.*
import java.net.*
URL url = new URL(
"www.my-web-service.com/api/whatever?theParam=" +
${theRelevantContextVariable});
URLConnection urlConnection = url.openConnection();
// if necessary to read response data:
// BufferedReader bufferedReader = new BufferedReader(
// new InputStreamReader(urlConnection.getInputStream()));
// String something = bufferedReader.readLine();
// etc.
]]>
</script>
<script-language>groovy</script-language>
<execution-type>onEntry</execution-type>
</action>
</actions>
</state>
You may need a POST request instead, in which case you'd implement the web service call differently. But in any case you'd write the web service code in an action tag. Something like this should work.

connect java metro client to wcf service with sessions

I need to connect a java metro client to a wcf service for a project I'm cuurently working on. I used the tutorial at click.
Everything seems to work properly until I want to add sessions to my service. When I add <reliableSession enabled="true" /> to my config file, the client isn't able to reload the wcf service.
config file:
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="false" logMalformedMessages="false"
logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="false" />
</diagnostics>
<services>
<service name="Service" behaviorConfiguration="ServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="" bindingConfiguration="interopBinding" binding="metroBinding" contract="IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
<!-- To configure the service certificate -->
<serviceCredentials>
<serviceCertificate storeLocation="LocalMachine" storeName="Root" x509FindType="FindBySubjectDistinguishedName" findValue="CN=go2.openscrolling" />
<clientCertificate>
<authentication certificateValidationMode="PeerOrChainTrust" />
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<metroBinding>
<binding name="interopBinding" messageEncoding="Text">
<security mode="MutualCertificate" establishSecurityContext="false" algorithmSuite="Basic128"/>
<!--<reliableSession enabled="true" />-->
</binding>
</metroBinding>
</bindings>
<extensions>
<bindingExtensions>
<add name="metroBinding" type="Microsoft.ServiceModel.Interop.Metro.Configuration.MetroBindingCollectionElement, Microsoft.ServiceModel.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4fc38efee625237e"/>
</bindingExtensions>
</extensions>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

TCP error 10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full

I am getting this TCP error: (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) occurred while transmitting data.
Apparently I start getting this error if I try to transfer any file over 50 MB.
I am using WCF. I have web services written in Java/Tomcat.
Could it be a problem in server-side configurations?
The server is Tomcat, can you tell me which value to customize in that case?
<bindings>
<basicHttpBinding>
<binding name="MyWebService1SoapHttpPortBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:11:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="4000000" maxReceivedMessageSize="99999999"
messageEncoding="Mtom" textEncoding="utf-8" transferMode="StreamedRequest"
useDefaultWebProxy="true">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://[IP]/Transfer"
binding="basicHttpBinding" bindingConfiguration="MyWebService1SoapHttpPortBinding"
contract="Transfer" name="MyWebService1SoapHttpPort" />
</client>
If you take your error message and google it you will find many answers.
A TCP error (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full)
Here is one.
http://support.microsoft.com/kb/196271

Categories

Resources