I have camera that supports Onvif. Calling OnVif SOAP GetDeviceInformation
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetDeviceInformation
xmlns="http://www.onvif.org/ver10/device/wsdl"/>
</s:Body>
</s:Envelope>
I get an answer when using SoapUI. I created simple WCF console app to call the same method - no answer from camera.
I checked with wireshart the messages sent:
SoapUI:
Frame 8858: 680 bytes on wire (5440 bits), 680 bytes captured (5440 bits) on interface 0
Ethernet II, Src: IntelCor_fc:da:96 (b4:b6:76:fc:da:96), Dst: Shenzhen_a4:9f:e8 (e8:ab:fa:a4:9f:e8)
Internet Protocol Version 4, Src: 10.0.0.8, Dst: 10.0.0.102
Transmission Control Protocol, Src Port: 61385, Dst Port: 888, Seq: 1, Ack: 1, Len: 626
Hypertext Transfer Protocol
POST /onvif/device_service HTTP/1.1\r\n
Accept-Encoding: gzip,deflate\r\n
Content-Type: application/soap+xml;charset=UTF-8;action="http://www.onvif.org/ver10/device/wsdl/GetDeviceInformation"\r\n
Content-Length: 322\r\n
[Content length: 322]
Host: 10.0.0.102:888\r\n
Connection: Keep-Alive\r\n
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)\r\n
\r\n
[Full request URI: http://10.0.0.102:888/onvif/device_service]
[HTTP request 1/1]
[Response in frame: 8891]
File Data: 322 bytes
eXtensible Markup Language
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetDeviceInformation
xmlns="http://www.onvif.org/ver10/device/wsdl"/>
</s:Body>
</s:Envelope>
WCF Client:
Frame 11631: 315 bytes on wire (2520 bits), 315 bytes captured (2520 bits) on interface 0
Ethernet II, Src: IntelCor_fc:da:96 (b4:b6:76:fc:da:96), Dst: Shenzhen_a4:9f:e8 (e8:ab:fa:a4:9f:e8)
Internet Protocol Version 4, Src: 10.0.0.8, Dst: 10.0.0.102
Transmission Control Protocol, Src Port: 61420, Dst Port: 888, Seq: 282, Ack: 1, Len: 261
[2 Reassembled TCP Segments (542 bytes): #11629(281), #11631(261)]
Hypertext Transfer Protocol
POST /onvif/device_service HTTP/1.1\r\n
Content-Type: application/soap+xml; charset=utf-8; action="http://www.onvif.org/ver10/device/wsdl/GetDeviceInformation"\r\n
Host: 10.0.0.102:888\r\n
Content-Length: 261\r\n
[Content length: 261]
Expect: 100-continue\r\n
Accept-Encoding: gzip, deflate\r\n
Connection: Keep-Alive\r\n
\r\n
[Full request URI: http://10.0.0.102:888/onvif/device_service]
[HTTP request 1/1]
File Data: 261 bytes
eXtensible Markup Language
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetDeviceInformation
xmlns="http://www.onvif.org/ver10/device/wsdl"/>
</s:Body>
</s:Envelope>
Bellow WCF code after WSDL Onvif WSDL reference was added to project:
namespace OnVifInfo
{
class Program
{
static void Main(string[] args)
{
GetDeviceInfo(new Uri("http://10.0.0.102:888/onvif/device_service"));
}
private static void GetDeviceInfo(Uri uri)
{
string address = uri.AbsoluteUri.ToString();
var messageElement = new TextMessageEncodingBindingElement()
{
MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None)
};
HttpTransportBindingElement httpBinding = new HttpTransportBindingElement()
{
AuthenticationScheme = System.Net.AuthenticationSchemes.Negotiate
};
CustomBinding binding = new CustomBinding(messageElement, httpBinding);
OnVifWebService.DeviceClient service = new OnVifWebService.DeviceClient(binding, new EndpointAddress(address));
string model;
string firmwareVersion;
string serialNumber;
string hardwareId;
var response = service.GetDeviceInformation(out model, out firmwareVersion, out serialNumber, out hardwareId);
}
}
}
Any ideas why camera is not answering to WCF client?
Why there is reassemble line:
[2 Reassembled TCP Segments (542 bytes): #11629(281), #11631(261)]
in WCF client request, but not in SoapUI call
Problem was the Expect HTML header
Expect: 100-continue\r\n
When I added this to WCF code
System.Net.ServicePoint servicePoint = System.Net.ServicePointManager.FindServicePoint(service.Endpoint.Address.Uri);
servicePoint.Expect100Continue = false;
It removed the Expect header and I got the answer from the camera.
Related
I have in my flow an HTTP request (say, DOC Service) where I get a PDF from a service, and I have to send the PDF to an OCR application through another HTTP Request (say, OCR Service). I am receiving the PDF from DOC Service as application/pdf type, and the OCR Service is set to receive multipart/form-data type.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<flow name="on-mq-messageFlow" doc:id="eca15aeb-da46-491a-97e1-f73aa5fcd45b" >
<set-payload value='#[%dw 2.0
output application/json
---
read(payload,"application/json")]' doc:name="Set Payload" doc:id="929f7b70-ae47-4fe3-abd2-e89ae092899e" />
<set-variable value="#[payload]" doc:name="Set MQ Payload" doc:id="9716ed4b-4d16-4b9e-8ac8-1dab5646fe0f" variableName="mqPayload"/>
<http:request method="POST" doc:name="Doc Request" doc:id="0e92add3-d576-444d-8070-9d09e6e3c5c5" config-ref="DOC_configuration" path="${doc.request.path}" outputMimeType='multipart/form-data; boundary=----aA1bB2cC3dD4'>
<http:headers ><![CDATA[#[output application/java
---
{
"client-id" : "12345",
"client-secret" : "12345"
}]]]></http:headers>
<http:uri-params ><![CDATA[#[output application/java
---
{
"doc_id" : payload.data.ID
}]]]></http:uri-params>
</http:request>
<http:request method="POST" doc:name="Send Doc to OCR" doc:id="76f60ddb-f570-42be-b85e-ccb2d2ae3703" config-ref="OCR_Request_configuration" path="${ocr.request.path}" outputMimeType="multipart/form-data; boundary=----aA1bB2cC3dD4">
<http:body ><![CDATA[#[%dw 2.0
output multipart/form-data
---
{
parts: {
file: {
headers: {
"Content-Type": payload.^mimeType
},
content: payload
},
id: {
headers: {
"Content-Type": "text/plain"
},
content: vars.mqPayload.data.ID
}
}
}]]]></http:body>
<http:headers ><![CDATA[#[output application/java
---
{
"client-id" : "12345",
"Accept" : "*/*",
"client-secret" : "12345",
"Content-Type" : "multipart/form-data; boundary=----aA1bB2cC3dD4"
}]]]></http:headers>
</http:request>
<ee:transform doc:name="Final Response" doc:id="cf68dbc1-cee3-4809-9511-a0794be2b5f7">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{
"status": "Success",
message: "Completed"
}
]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
</mule>
I have to add another text field along with the PDF file before sending the payload to OCR Service. For that, I have defined payload as multipart/form-data by selecting the elements of parts of form-data and modifying it like given in the answer here, but getting below error. I have also set MimeType for both DOC Service and OCR Service as multipart/form-data.
ERROR 2020-12-05 21:57:57,159 [[MuleRuntime].cpuLight.02: [doc-process-api].on-mq-messageFlow.CPU_LITE #6ec62e93] [event: 0e82ca00-3717-11eb-ab69-005056ac6a26] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:
********************************************************************************
Message : "javax.mail.internet.ParseException - Missing start boundary, while reading `payload` as MultiPart.
Trace:
at main (Unknown), while writing MultiPart.
Trace:
at main (Unknown)" evaluating expression: "%dw 2.0
output multipart/form-data
---
{
parts: {
file: {
headers: {
"Content-Type": payload.^mimeType
},
content: payload
},
external_id: {
headers: {
"Content-Type": "text/plain"
},
content: vars.mqPayload.data.ID
}
}
}".
Element : on-mq-messageFlow/processors/4 # doc-process-api:on-mq-message.xml:46 (Send Doc to OCR)
Element XML : <http:request method="POST" doc:name="Send Doc to OCR" doc:id="76f60ddb-f570-42be-b85e-ccb2d2ae3703" config-ref="OCR_Request_configuration" path="${ocr.request.path}" outputMimeType="multipart/form-data; boundary=----aA1bB2cC3dD4">
<http:body>#[%dw 2.0
output multipart/form-data
---
{
parts: {
file: {
headers: {
"Content-Type": payload.^mimeType
},
content: payload
},
external_id: {
headers: {
"Content-Type": "text/plain"
},
content: vars.mqPayload.data.ID
}
}
}]</http:body>
<http:headers>#[output application/java
---
{
"client-id" : "12345",
"Accept" : "*/*",
"client-secret" : "12345",
"Content-Type" : "multipart/form-data; boundary=----aA1bB2cC3dD4"
}]</http:headers>
</http:request>
Error type : MULE:EXPRESSION
Payload Type : org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.runtime.api.el.ExpressionExecutionException: javax.mail.internet.ParseException - Missing start boundary, while reading `payload` as MultiPart.
Trace:
at main (Unknown), while writing MultiPart.
Trace:
at main (Unknown)
at org.mule.weave.v2.el.WeaveExpressionLanguageSession.doEvaluate(WeaveExpressionLanguageSession.scala:130)
at org.mule.weave.v2.el.WeaveExpressionLanguageSession.evaluate(WeaveExpressionLanguageSession.scala:77)
at org.mule.weave.v2.el.WeaveExpressionLanguageSession.evaluate(WeaveExpressionLanguageSession.scala:103)
at org.mule.runtime.core.internal.el.dataweave.DataWeaveExpressionLanguageAdaptor$1.evaluate(DataWeaveExpressionLanguageAdaptor.java:252)
at org.mule.runtime.core.internal.el.DefaultExpressionManagerSession.evaluate(DefaultExpressionManagerSession.java:38)
at org.mule.runtime.core.privileged.util.attribute.ExpressionAttributeEvaluatorDelegate.resolveExpressionWithSession(ExpressionAttributeEvaluatorDelegate.java:70)
at org.mule.runtime.core.privileged.util.attribute.ExpressionAttributeEvaluatorDelegate.resolve(ExpressionAttributeEvaluatorDelegate.java:56)
at org.mule.runtime.core.privileged.util.AttributeEvaluator.resolveTypedValue(AttributeEvaluator.java:104)
at org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionValueResolver.resolveTypedValue(ExpressionValueResolver.java:122)
at org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionTypedValueValueResolver.resolve(ExpressionTypedValueValueResolver.java:46)
at org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionTypedValueValueResolver.resolve(ExpressionTypedValueValueResolver.java:29)
at org.mule.runtime.module.extension.internal.runtime.resolver.ResolverUtils.resolveRecursively(ResolverUtils.java:90)
at org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet.resolve(ResolverSet.java:109)
at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.getResolutionResult(ComponentMessageProcessor.java:586)
at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.lambda$apply$6(ComponentMessageProcessor.java:194)
at org.mule.runtime.core.api.util.func.CheckedFunction.apply(CheckedFunction.java:19)
at org.mule.runtime.core.api.rx.Exceptions.lambda$checkedFunction$2(Exceptions.java:84)
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:381)
at reactor.core.publisher.FluxFlatMap$FlatMapMain.tryEmit(FluxFlatMap.java:532)
at reactor.core.publisher.FluxFlatMap$FlatMapInner.onNext(FluxFlatMap.java:974)
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2071)
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:162)
at reactor.core.publisher.FluxFlatMap$FlatMapInner.onSubscribe(FluxFlatMap.java:964)
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90)
at reactor.core.publisher.MonoCurrentContext.subscribe(MonoCurrentContext.java:35)
at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)
at reactor.core.publisher.Mono.subscribe(Mono.java:3858)
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:420)
at org.mule.runtime.core.privileged.processor.chain.AbstractMessageProcessorChain$1.onNext(AbstractMessageProcessorChain.java:292)
at org.mule.runtime.core.privileged.processor.chain.AbstractMessageProcessorChain$1.onNext(AbstractMessageProcessorChain.java:285)
at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:204)
at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:345)
at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:204)
at reactor.core.publisher.FluxContextStart$ContextStartSubscriber.tryOnNext(FluxContextStart.java:111)
at reactor.core.publisher.FluxContextStart$ContextStartSubscriber.tryOnNext(FluxContextStart.java:109)
at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.tryOnNext(FluxMapFuseable.java:303)
at reactor.core.publisher.FluxContextStart$ContextStartSubscriber.tryOnNext(FluxContextStart.java:109)
at reactor.core.publisher.FluxPublishOn$PublishOnConditionalSubscriber.runAsync(FluxPublishOn.java:866)
at reactor.core.publisher.FluxPublishOn$PublishOnConditionalSubscriber.run(FluxPublishOn.java:939)
at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84)
at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:111)
at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
To fix that I tried adding boundary in headers as Content-Type like below, and still getting the same error.
"Content-Type: "multipart/form-data; boundary=----aA1bB2cC3dD4"
Here I don't need to parse anything, just handover the PDF from one service to another service, but by adding an extra field. How can I achieve this? Any help is appreciated.
The error is happening because you are miss typing the DOC service as multipart so DataWeave attempts to read the PDF as such. The mime type parameter affects the output of your operation, saying "this is the type I produce". But in the case of HTTP, that is automatically determined based on the "Content-Type" header, you do not need to specify the mime types beyond your DataWeave transformation for the ORC service.
I accepted #afelisatti's answer since that was the key point that helped me fix the error which I was getting; I am posting here how I was able to send the PDF over HTTP request in Mule 4.
Removed the output mime type I set for the OCR Service HTTP Request and set output mime type as application/pdf
Set the output payload from DOC Service (PDF) in Set Payload
Took out the payload which I have defined in OCR HTTP Request and put it in a transform message like below and made few changes. The changes are; added boundary along with output type, set a file name for the document in 'Content Disposition' as filename.
<ee:transform doc:name="Multipart Payload with ID" doc:id="cf68dbc1-cee3-4809-9511-a0794be2b5f7">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
import * from dw::module::Multipart
output multipart/form-data; boundary=----aA1bB2cC3dD4"
---
{
parts: {
file: {
headers: {
"Content-Disposition": {
"name": "file",
"filename": vars.mqPayload.data.ID ++ "_Doc.pdf" as String
},
"Content-Type": "application/pdf"
},
content: payload
},
id: {
headers: {
"Content-Type": "text/plain"
},
content: vars.mqPayload.data.ID
}
}
}
]]></ee:set-payload>
</ee:message>
</ee:transform>
Added boundary and charset for muiltpart/form-data Content-Type header in OCR HTTP Request
"Content-Type":"multipart/form-data; charset=UTF-8; boundary=----aA1bB2cC3dD4"
The important thing is to set boundary and charset in HTTP Request headers and the same boundary is defined in the formdata payload, otherwise will result in bad request of boundary mismatch.
We are kind of stuck and do not know how to send attachments in mule message. We have some code in place that adds outbound attachments, but the values for Content-Disposition and Content-Type are autogenerated by mule and are not matching what is expected on the server. I have pasted the message that we are generating, the message that is expected (note the differences on content-types and content-dispositions).
The content-disposition has to be “inline” on payload and “attachment” on the part of data-file.xml, but instead mule generates Content-Disposition: form-data; name="payload" and Content-Disposition: form-data; name="data-file.xml"
This is the code snippet we are using to generate attachments:
ByteArrayDataSource ds = new org.mule.message.ds.ByteArrayDataSource((byte[])docInput.getDataSet(),ATTACHMENT_FILE_NAME,"application/pdf");
DataHandler dh = new javax.activation.DataHandler(ds);
msg.addOutboundAttachment(ATTACHMENT_FILE_NAME, dh);
Generated-Message-By_mule
POST /Operations/GenerateDocument HTTP/1.1
X-MULE_ENDPOINT: http://bxl-rs-d1-vm:42420/Operations/GenerateDocument
X-MULE_CORRELATION_SEQUENCE: -1
X-MULE_ENCODING: UTF-8
X-MULE_ROOT_MESSAGE_ID: be11dc40-a0af-11e4-89da-080027001cc8
Client-Authorization: YyoAjWLrpsySg7Euxf9zs3S/ujAPjFuRkT7di6/Dk9o=
Content-Type: multipart/mixed; boundary=" WeqbofBr94jK6QxpiWP36xMWse3bxwG21uQZed6”
Date: Tue, 20 Jan 2015 14:22:20 GMT
X-MULE_CORRELATION_GROUP_SIZE: -1
Accept: application/xml
X-MULE_SESSION: rO0ABXNyACNvcmcubXVsZS5zZXNzaW9uLkRlZmF1bHRNdWxlU2Vzc2lvbi7rdtEW7GGKAwAFWgAFdmFsaWRMAA1mbG93Q29uc3RydWN0dAAmTG9yZy9tdWxlL2FwaS9jb25zdHJ1Y3QvRmxvd0NvbnN0cnVjdDtMAAJpZHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wACnByb3BlcnRpZXN0AA9MamF2YS91dGlsL01hcDtMAA9zZWN1cml0eUNvbnRleHR0ACdMb3JnL211bGUvYXBpL3NlY3VyaXR5L1NlY3VyaXR5Q29udGV4dDt4cAFwdAAkYmUxMjc4ODAtYTBhZi0xMWU0LTg5ZGEtMDgwMDI3MDAxY2M4c3IAJWphdmEudXRpbC5Db2xsZWN0aW9ucyRTeW5jaHJvbml6ZWRNYXAbc/kJS0s5ewMAAkwAAW1xAH4AA0wABW11dGV4dAASTGphdmEvbGFuZy9PYmplY3Q7eHBzcgAkb3JnLm11bGUudXRpbC5DYXNlSW5zZW5zaXRpdmVIYXNoTWFwndHZ72dFzgADAAB4cHcMP0AAAAAAABAAAAABdAAMT3BlcmF0aW9uVmFydAAQZ2VuZXJhdGVEb2N1bWVudHhxAH4ACXhweA==
User-Agent: Jakarta Commons-HttpClient/3.1
Host: bxl-rs-d1-vm:42420
Content-Length: 16645
--WeqbofBr94jK6QxpiWP36xMWse3bxwG21uQZed6
Content-Disposition: form-data; name="payload"
Content-Type: application/octet-stream; charset=ISO-8859-1
Content-Transfer-Encoding: binary
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns12:GenerateDocumentRequest xmlns:ns2="http://www.sodexo.com/CRM-Integration-Push" xmlns:ns3="http://www.sodexo.com/CRM-Integration-Update" xmlns:ns4="http://www.sodexo.com/CRM-Integration-PushFeedback" xmlns:ns5="http://www.sodexo.be/schemas/organization-api/1.0" xmlns:ns6="http://www.sodexo.be/schemas/organization-api/Phoenix-Organization-Update" xmlns:ns7="http://www.sodexo.com/CRM-Integration-UpdateFeedback" xmlns:ns8="http://www.sodexo.com/CRM-Address-Management" xmlns:ns9="http://net.sxpbelux.eurodb.services/eurodbServiceSchema-addressRequest" xmlns:ns10="http://net.sxpbelux.eurodb.services/eurodbServiceSchema-resultType" xmlns:ns11="http://www.sodexo.com/CRM-Document-Management" xmlns:ns12="http://schemas.datacontract.org/2004/07/Compro.Services.Contracts.DataContracts" xmlns:ns13="http://schemas.datacontract.org/2004/07/System" xmlns:ns14="http://net.sxpbelux.eurodb.services/eurodbServiceSchema-addressSearchRequest" xmlns:ns15="http://www.sodexo.com/CRM-Integration-Base" xmlns:ns16="http://www.sodexo.be/schemas/organization-api/Phoenix-OrganizationServices-Base" xmlns:ns17="http://www.sodexo.be/schemas/organization-api/Phoenix-Organization-UpdateFeedback" xmlns:ns18="http://net.sxpbelux.eurodb.services/eurodbServiceSchema-searchAddressResultType"><ns12:AttachmentFiles xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><ns12:BusinessContext>ServiceVoucher</ns12:BusinessContext><ns12:BusinessReference>Work_Voucher_Assigned</ns12:BusinessReference><ns12:CommunicationKey>CommunicationKey</ns12:CommunicationKey><ns12:DataFile>data-file.xml</ns12:DataFile><ns12:FileFormat>DOCX</ns12:FileFormat></ns12:GenerateDocumentRequest>
--WeqbofBr94jK6QxpiWP36xMWse3bxwG21uQZed6
Content-Disposition: form-data; name="data-file.xml"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:DocumentData xmlns:ns2="http://www.sodexo.com/CRM-Integration-Template">
<Contacts>
<Contact>
<email>email#abc.com</email>
<firstName>firstName</firstName> ....
Message_expected_by_server
POST http://besvc-hq1000057:42420/Operations/GenerateDocumentWithAttachment/ HTTP/1.1
Date: Wed, 26 Nov 2014 13:31:24 GMT
Accept: application/xml
X-Compro-Username: ASI
Client-Authorization: S/rumqB+P0jfzY54eSeAGrKeMCfy7RYizno5A8D0ulI=
Content-Type: multipart/mixed; boundary="d1261136-19f2-463e-ac7e-e8925c807c7d"
Host: besvc-hq1000057:42420
Content-Length: 26128
Expect: 100-continue
Connection: Keep-Alive
--d1261136-19f2-463e-ac7e-e8925c807c7d
Content-Type: application/xml; charset=utf-8
Content-Disposition: inline
[... some xml data ...]
--d1261136-19f2-463e-ac7e-e8925c807c7d
Content-Type: application/xml; charset=utf-8
Content-Disposition: attachment; filename=order_created_badcom_data.xml
[... some xml content ...]
--d1261136-19f2-463e-ac7e-e8925c807c7d
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Content-Disposition: attachment; filename=a.docx
[... some binary content ...]
--d1261136-19f2-463e-ac7e-e8925c807c7d
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Content-Disposition: attachment; filename=a2.docx
[... some binary content ...]
--d1261136-19f2-463e-ac7e-e8925c807c7d--
If you have any ideas on how to get this to work, kindly let us know.
Thanks and regards,
Priya
Can you try setting the Content-Type on the message as follows:
<set-property propertyName="Content-Type" value="application/pdf" doc:name="Content-Type"/>
You can replace the 'application/pdf' with your desired value. The same applies to the other property you want to modify.
HTH
I finally figured out that this is mule's limitation - we do not have control over setting content-disposition value when adding attachments using message.addOutboundAttachment() method.
The workarounds for this is to have your own http transport connector implemented or implement your client using any rest client framework or http client libraries.
The following will work fine and will set attachment with the message :-
<set-attachment value="#[message.payload]" contentType="application/pdf" attachmentName="#[message.inboundProperties['originalFilename']]" doc:name="Attachment" />
Where you can replace #[message.inboundProperties['originalFilename']] directly with file name or can keep as same if you are using a file inbound endpoint
I have found this post that worked for me but I recieved a HTML response instead of a XML one which is what I need for my app.
How to consume SOAP web service in SENCHA TOUCH?
This is my request to my server... I know I should be doing a POST action as this guy was told, but I still get a root node error.
Is this the proper way to consume a WebService, or there is another way to consume in Sencha using data models and stores? I have already saw an example using CFC but I am using IIS 7.5
POST /url/mobilews.asmx HTTP/1.1
Host: 10.0.1.182
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/HelloWorld"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorld xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
Ext.Ajax.request({
method: 'GET',
url: 'http://url/mobileservice/mobilews.asmx?op=HelloWorld',
params: { method: 'HelloWorld', format: 'json' },
success: function (response, request) {
alert('Working!');
alert(response.responseText);
},
failure: function (response, request) {
alert('Not working!');
}
});
Here goes the error message:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Receiver</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
I am trying to pass header when i post XML Data in VB.Net.
It needs to look like this :
POST /test1.asmx HTTP/1.1
Host: www.test1.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://test1.org/PostApplication_V5"
I am using the following :
Req.Headers.Add("POST /", "test1.asmx HTTP/1.1")
Req.Headers.Add("HOST", "www.test1.com")
Req.Headers.Add("Content-Type", "text/xml; charset=utf-8")
Req.Headers.Add("Content-Length", "length")
Req.Headers.Add("SOAPAction", """http://test1.org/PostApplication_V5""")
Its not working
<POST /test1.asmx HTTP/1.1>
<Host: www.test1.com>
<Content-Type: text/xml; charset=utf-8>
<Content-Length: length>
<SOAPAction: "http://test1.org/PostApplication_V5">
</POST /test1.asmx HTTP/1.1>
</Host: www.test1.com>
</Content-Type: text/xml; charset=utf-8>
</Content-Length: length>
</SOAPAction: "http://test1.org/PostApplication_V5">
I am using cxf 2.7.7 and using MTOM with https ... and it is working ok with cxf java client.
However when I send a message though SOAP UI client, and at the server side (in my endpoint implementation class) I try to access any of the methods of the Datahandler object (please see abridged code below) then I get java.lang.NullPointerException in org.apache.cxf.attachment.LazyDataSource. Please note that call to any .getXXX method gives exception (these calls translate to corresponding call to LazyDataSource.getXXX methods ... and looks like LazyDataSource is null)
This does NOT happen when I send requests through java client. Happens only when I use SOAPUI for request
#WebService(targetNamespace = "http://webservice.dcca.dell.com",
portName = "ObjectMTOMService", serviceName = "ObjectMTOMServiceService")
public class ObjectMTOMServiceImpl implements ObjectMTOMService {
#Resource
WebServiceContext wsContext;
public ObjectStoreResp uploadObject(ObjectStoreReq objectReqParam) {
DataHandler objHandler = objectReqParam.getObjData();
try {
if (objHandler != null)
{
String objName=objHandler.getName();
String contentType=objHandler.getContentType();
InputStream iStream= objHandler.getDataSource().getInputStream();
}
catch (Exception e) {
e.printStackTrace();
respParam.setRespCode(-1);
return (respParam);
}
}
The exception I see is as follows
java.lang.NullPointerException
at org.apache.cxf.attachment.LazyDataSource.getName(LazyDataSource.java:73)
at javax.activation.DataHandler.getName(DataHandler.java:191)
at com.dell.dcca.webservice.objectmtomservice.ObjectMTOMServiceImpl.uploadObject(ObjectMTOMServiceImpl.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
........ <<< removed lot of stack trace for brevity >>>
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1555)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
java.lang.NullPointerException
The message that SOAPUI sends is as follows << I have approximated this -- copying and pasting from SOAPUI log >>
POST https://160.110.73.35:8443/ObjectMTOMService/services/ObjectMTOMService HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: multipart/related; type="application/xop+xml"; start="<rootpart#soapui.org>"; start-info="text/xml"; boundary="----=_Part_13_756617.1389959552144"
SOAPAction: "http://InteropBaseAddress/interop/header"
MIME-Version: 1.0
Content-Length: 5432
Host: 160.110.73.35:8443
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
------=_Part_13_756617.1389959552144"
"Content-Type: application/octet-stream; name=InfantHealthcare.jpg"
Content-Transfer-Encoding: binary
Content-ID: <images.jpg>
Content-Disposition: attachment; name="images.jpg"; filename="InfantHealthcare.jpg
<< file contents ... >>
Any inputs welcome.
If anyone has tried MTOM with SOAPui client and Axis 2.7.X onwards combination, let me know
Thanks a ton for your help
Yogesh
This problem was because I was using incorrect setting in SOAPUI that was sending the Data as Null. I consider this as a CXF bug that it gives a Null Pointer exception. There should be a safer way of reporting that I have a null attachment. Anyways, the question is how did I fix it.
The below link, does give information but IMHO it is a bit ambiguous ( or may be I did not interpret it right :-( - had to read it many times over
http://www.soapui.org/SOAP-and-WSDL/adding-headers-and-attachments.html
My incorrect way of specifying the request SOAP message in SOAP UI was
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://webservice.dcca.dell.com/types">
<soapenv:Header/>
<soapenv:Body>
<typ:objectStoreReq>
<typ:ObjData>cid:183942097334</typ:ObjData>
<typ:objMetadata>
<typ:objName>img</typ:objName>
<typ:organizationName>Dell</typ:organizationName>
</typ:objMetadata>
</typ:objectStoreReq>
</soapenv:Body>
</soapenv:Envelope>
The correct way is ( note that instead of filling a part id in "Objdata" element- using "cid: id" which sends it as base64 encoded we have to specify XOP Include element referring to the second Mime-Part using href.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://webservice.dcca.dell.com/types">
<soapenv:Header/>
<soapenv:Body>
<typ:objectStoreReq>
<typ:ObjData>
<inc:Include
href="cid:myImage.jpg"
xmlns:inc="http://www.w3.org/2004/08/xop/include"
/>
</typ:ObjData>
<typ:objMetadata>
<typ:objName>img</typ:objName>
<typ:organizationName>Dell</typ:organizationName>
</typ:objMetadata>
</typ:objectStoreReq>
</soapenv:Body>
</soapenv:Envelope>
With this my SOAP-UI messages were very much palatable to my service :-)