I have implemented an interface to an erp-system with WCF. The interface works fine nearly all the time. Every 2-3 weaks in the erp-system a deadlock occurs and then I get a System.ServiceModel.MessageHeaderException when I try to read the answer. Somehow I get a success and a failure message from the erp-system an I can't read this. I have not enabled logging for the wcf right now.
How can I prevent this error? Can I interpret messages with multiple headers?
Complete error:
System.ServiceModel.MessageHeaderException: Multiple headers with name 'Action' and namespace 'http://www.w3.org/2005/08/addressing' found.
I too faced encountered same error while working on aif services which is basically based on top of dotnet wcf services. My Service operation was returning a List DataContract of a type which itself having a List DataContract as DataMember.
There was a problem in the code which resulted in corrupted response header
Here is complete metadata
<HMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContractHMPackageItemDefaultsContract: Dynamics.Ax.Application.HMPackageItemDefaultsContract>}
Items were not seperated by commas (,). due to a code glitch
contract = new HMPackageItemDefaultsContract();
switch (line.HMProductType)
{
case HMInventType::Laboratory:
hmLaboratoryDefault = HMLaboratoryDefault::findByPackageDefinitionLine(line);
while select hmLaboratoryDefault
{
contract.parmCollectionDate(hmLaboratoryDefault.CollectionDate);
contract.parmInstructionstoPatient(hmLaboratoryDefault.Instructions);
contract.parmNotestoPharmacy(hmLaboratoryDefault.Notes);
contract.parmSpecimenSource(hmLaboratoryDefault.HMSpecimenSource);
list.addEnd(contract);
}
break;
contract was not being instantiated on each while iteration to add it to list.
Took me 3 hour to figure it out after doing compilation, cleaning up XPPIL and doing full cil.
I just figured out there is one more scenario where it fails, when you have DataMemberberContract returning enum type with a fixed set of items with their corresponding integer values and you returning an enum integer value out of bound.
WCF doesn't give any error message specific to the actual error, it just fails with below message
Multiple headers with name 'Action' and namespace 'http://www.w3.org/2005/08/addressing' found.
Hope it help folks out there who encounter such concealed exceptions.
Related
I'm using PrimeFaces 6.0. I used selectOneRadio tag and populates the list from database, and then I would like to use the selected value to identify the type of document selected and pass this to fileUploadListener so that the right document type is attached to file being uploaded. How do I pass that selected value?
<p:selectOneRadio id="docType" value="#{fileUploadBean.docType}" layout="grid" columns="1">
<f:selectItems var="document" value="#{fileUploadBean.docDescriptionList}" itemLabel="#{docType}" itemValue="#{docType}" />
</p:selectOneRadio>
<p:fileUpload id="docFile" value="#{fileUploadBean.file}" mode="advanced" allowTypes="/(\.|\/)(pdf)$/"
fileUploadListener="#{fileUploadBean.uploadFile}" multiple="true" update="messages">
</p:fileUpload>
<p:growl id="messages" showDetail="true" />
You'll need to add variable for allowed types and then update it when radio button is changed:
<p:selectOneRadio id="docType"
value="#{fileUploadBean.docType}"
layout="grid"
columns="1">
<p:ajax listener="#{fileUploadBean.updateAllowTypes}" update="#form" />
<f:selectItems var="document"
value="#{fileUpoadBean.docDescriptionList}"
itemLabel="#{docType}"
itemValue="#{docType}" />
</p:selectOneRadio>
<p:fileUpload id="docFile"
value="#{fileUploadBean.file}"
mode="advanced"
allowTypes="#{fileUploadBean.allowTypes}"
fileUploadListener="#{fileUploadBean.uploadFile}"
multiple="true"
update="messages">
</p:fileUpload>
And in Java bean:
private String allowTypes; //getters and setters
...
public void updateAllowTypes(){
allowTypes = ... //Specify allowed types
}
How I send an static value inside ConverterParameter such as a number?
<Label Style="{DynamicResource ListItemDetailTextStyle}" Text="{Binding Information, Converter={StaticResource CutStringConverter}, ConverterParameter={100}}" />
You probably need to include the type then. So either do it inline like this: ConverterParameter={x:Int32 100}.
Or write it more verbose:
<Label>
<Label.Text>
<Binding Path="Information" Converter="{StaticResource CutStringConverter}">
<Binding.ConverterParameter>
<x:Int32>100</x:Int32>
</Binding.ConverterParameter>
</Binding>
</Label.Text>
</Label>
Or, to be complete, add a static resource to your page (or whatever the container is), like:
<ContentPage.Resources>
<x:Int32 x:Key="IntHundred">100</x:Int32>
</ContentPage.Resources>
And reference that: ConverterParameter={StaticResource IntHundred}
When I create a model I would like to save images for a model. I am using PrimeFaces fileUpload component. When I save pictures I want to know to which model particular image refers to. That's why I need to send id of a model to backing bean.
Is there any possibility to send id of model to fileUploadListener?
<h:form enctype="multipart/form-data">
<p:panelGrid columns="2">
<h:outputLabel for="hotelName" value="#{msg.hotelName}"/>
<p:inputText value="#{apartmentNew.name}" id="hotelName"/>
<h:outputLabel for="hotelDescription" value="#{msg.hotelDescription}"/>
<p:inputText value="#{apartmentNew.description}" id="hotelDescription"/>
<h:outputLabel for="hotelImages" value="#{msg.hotelImages}"/>
<h:form enctype="multipart/form-data">
<p:fileUpload id="hotelImages"
fileUploadListener="#{apartments.handleImageUpload}"
mode="advanced"
sizeLimit="10000000"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/">
</p:fileUpload>
</h:form>
</p:panelGrid>
<p:commandButton id="saveApartmentButton" value="#{msg.save}" action="save"/>
<p:commandButton id="cancelCreationApartmentButton" value="#{msg.cancel}"
action="cancel"/>
</h:form>
Not via request parameters. You can do so via component attributes.
E.g.
<p:fileUpload ...>
<f:attribute name="foo" value="bar" />
</p:fileUpload>
with
String foo = (String) event.getComponent().getAttributes().get("foo"); // bar
I needed to pass a key parameter along with the uploaded file. I found that fileUploadListener executes during the APPLY_REQUEST_VALUES phase, so I could not use an EL expression in the f:attribute tag. I also tried to find the value using event.getComponent().findComponent("id"), but although the component was present, the value was null. I think a #ViewScoped bean would fix the missing value, but I am stubbornly attempting to keep my beans at #RequestScoped until I have absolutely no other option. Ultimately, I had to use FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id") which I got from http://forum.primefaces.org/viewtopic.php?f=3&t=6432
Error in types:
String foo = event.getComponent().getAttributes().get("foo");
Instead, do it this way:
Object foo = event.getComponent().getAttributes().get("foo");
Integer foo = (Integer) event.getComponent().getAttributes().get("foo");
You can use:
<div onclick="#{myBean.myMethod(myParam)}" >
<p:fileUpload id="fileUpload" fileUploadListener="#{myBean.onFileUplod}" mode="advanced" dragDropSupport="true"
update=":messages" process="#this" >
</p:fileUpload>
</div>
Method in myBean:
public void myMethod(String myParam) {
selectedMyParam = myParam;
}
Then you can use selectedMyParam in onFileUpload method.
Why is it that for the below code, when I use t:commandButton it works fine and in case of a4j:commandButton it gives NullPointerException on uploadedFile.getInputStream() ?
<h:form enctype="multipart/form-data">
<t:inputFileUpload value="#{fileUploadController.uploadedFile}"/>
<t:commandButton action="#{fileUploadController.insertFile}"/>
</h:form>
Thinking that , in struts 1.2, say a function public ActionForward abc(){ return null;} will return to the same page.
But i got this exception.
java.lang.NullPointerException
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:441)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
How to get into the same page?
You can use
return mapping.getInputForward();
In struts-config.xml, write a forward tag inside your action tag like this.
<action ...>
<forward name = "samePage" path="..."/>
</action>
Now, in your code use
mapping.findForward("samePage");