web stats
Receiving SOAP Envelope in Custom Web Service - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-29-2013, 05:06 AM
mlizana mlizana is offline
Mirth Newb
 
Join Date: Jun 2011
Location: Mataró (Barcelona)
Posts: 24
mlizana is on a distinguished road
Unhappy Receiving SOAP Envelope in Custom Web Service

Hi, I have a WebService Listener, that uses a customized Web Service, using my own WSDL, referenced with JAX annotations in the Java class that extends AcceptMessage class from Mirth.

The Web Service is published correctly, I send a message using another channel, that gets the soap envelope using the WSDL definition obtained using the "Generate Envelope" options in the Web Service Sender connector, so the message is generated correctly.

But when I receive the message in the Web Service Listener, I receive a "null" value, and it crashes with this error:

Code:
[2013-01-29 13:56:53,017]  ERROR (com.mirth.connect.connectors.ws.WebServiceMessageReceiver:168): Error processing message in web service.  Channel: 9e980970-abf7-4a09-b343-59596caa2351
java.lang.NullPointerException
	at org.mule.umo.MessagingException.<init>(MessagingException.java:65)
	at org.mule.providers.AbstractServiceEnabledConnector.getMessageAdapter(AbstractServiceEnabledConnector.java:151)
	at com.mirth.connect.connectors.ws.WebServiceMessageReceiver.processData(WebServiceMessageReceiver.java:150)
	at com.mirth.connect.connectors.ws.S044Service.S044(S044Service.java:29)
I cannot know what happens before, because I don't know what SOAP envelope arrives with the message. I'm understanding that is some kind of namespace problem, or maybe Mirth is only capable of receiving message with the attribute "arg0"?

My Web Service class is developed as follows:

Code:
@WebService(wsdlLocation = "WEB-INF/wsdl/MA44.wsdl",
			targetNamespace = "http://CCI.Servicios/",
			serviceName = "MA44Service",
			name = "MA44Service", 
			portName = "MA44ServiceSoap")
public class MA44Service extends AcceptMessage {

	public MA44Service(WebServiceMessageReceiver webServiceMessageReceiver) {
		super(webServiceMessageReceiver);
	}

	@WebMethod(operationName = "MA44")
	@WebResult(name = "MA44Response")
	public String MA44(@WebParam(name="MensEntrada") String message) {
		return webServiceMessageReceiver.processData(message);
	}
}
I tried using also Request and Response Wrapper JAX annotations, but I don't know how really works.

Please, anyone have an idea?

Last edited by mlizana; 01-30-2013 at 03:23 AM.
Reply With Quote
  #2  
Old 01-29-2013, 09:04 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

Can you try using a packet sniffer to see the entire HTTP request and what it contains?
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 01-30-2013, 03:26 AM
mlizana mlizana is offline
Mirth Newb
 
Join Date: Jun 2011
Location: Mataró (Barcelona)
Posts: 24
mlizana is on a distinguished road
Default

Thanks Narupley for your response, this is what I get in wireshark:

Code:
<?xml version="1.0" ?><soapenv:Envelope xmlns:cci="http://CCI.Servicios/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>
      <cci:MA44>
         <cci:MensEntrada><hola xmlns="">lalalalla</hola></cci:MensEntrada>
      </cci:MA44>
   </soapenv:Body></soapenv:Envelope>

And this is the WSDL:

Code:
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://CCI.Servicios/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
targetNamespace="http://CCI.Servicios/">
	<types>
		<s:schema elementFormDefault="qualified" targetNamespace="http://CCI.Servicios/">
			<s:element name="MA44">
				<s:complexType>
					<s:sequence>
						<s:element name="MensEntrada">
							<s:complexType mixed="true">
								<s:choice maxOccurs="unbounded" minOccurs="0">
									<s:any processContents="lax"/>
								</s:choice>
							</s:complexType>
						</s:element>
					</s:sequence>
				</s:complexType>
			</s:element>
			<s:element name="MA44Response">
				<s:complexType>
					<s:sequence>
						<s:element name="MensSalida">
							<s:complexType mixed="true">
								<s:choice maxOccurs="unbounded" minOccurs="0">
									<s:any processContents="lax"/>
								</s:choice>
							</s:complexType>
						</s:element>
					</s:sequence>
				</s:complexType>
			</s:element>
		</s:schema>
	</types>
	<message name="MA44SoapIn">
		<part name="parameters" element="s0:MA44"/>
	</message>
	<message name="MA44SoapOut">
		<part name="parameters" element="s0:MA44Response"/>
	</message>
	<portType name="MA44ServiceSoap">
		<operation name="MA44">
			<input message="s0:MA44SoapIn"/>
			<output message="s0:MA44SoapOut"/>
		</operation>
	</portType>
	<binding name="MA44ServiceSoap" type="s0:MA44ServiceSoap">
		<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
		<operation name="MA44">
			<soap:operation soapAction="http://CCI.Servicios/MA44" style="document"/>
			<input>
				<soap:body use="literal"/>
			</input>
			<output>
				<soap:body use="literal"/>
			</output>
		</operation>
	</binding>
	<service name="MA44Service">
		<port name="MA44ServiceSoap" binding="s0:MA44ServiceSoap">
			<soap:address location="http://[servidor]:[puerto]/[plataformaInterfaces]/[NombreServicio]" />
		</port>
	</service>
</definitions>
Reply With Quote
  #4  
Old 01-31-2013, 12:10 AM
mlizana mlizana is offline
Mirth Newb
 
Join Date: Jun 2011
Location: Mataró (Barcelona)
Posts: 24
mlizana is on a distinguished road
Red face

Now I changed the class by this, adding the namespace also to the parameter, because it has the same namespace in the definition (CCI):

Code:
	@WebMethod(operationName = "MA44")
	@WebResult(name = "MA44Response")
	public String MA44(@WebParam(name="MensEntrada",targetNamespace="http://CCI.Servicios/") String message) {
		return webServiceMessageReceiver.processData(message);
	}
And now I obtain a blank message "", but not null. So, what's the problem now? I think it doesn't apply correctly the XML namespace of the SOAPBody content, but I don't know how to change it.

Any ideas?
Reply With Quote
  #5  
Old 01-31-2013, 01:30 AM
mlizana mlizana is offline
Mirth Newb
 
Join Date: Jun 2011
Location: Mataró (Barcelona)
Posts: 24
mlizana is on a distinguished road
Question

I debugged the node contents of the received message in the LoggingSOAPHandler.java class of Mirth source code, and I get this information:

Code:
ERROR 2013-01-31 10:22:19,147 [pool-1-thread-4] Server: Name: cci:MA44, Value: null, Prefix: cci, TextContent: lalala, NSURI: http://CCI.Servicios/
ERROR 2013-01-31 10:22:19,148 [pool-1-thread-4] Server: Name: #text, Value: 
ERROR 2013-01-31 10:22:19,148 [pool-1-thread-4] Server:          , Prefix: null, TextContent: , NSURI: null
It seems like after processing MA44 operation tag, it misses the "MensEntrada" tag...

I read this in Developing a Service:

Quote:
The @WebParam annotation is necessary as java interfaces do not store the Parameter name in the .class file. So if you leave out the annotation your parameter will be named arg0.
But I wrote the annotation in the param also with the corresponding namespace. Why the tag "MensEntrada" hasn't parsed correctly?

Thanks
Reply With Quote
  #6  
Old 01-31-2013, 05:30 AM
mlizana mlizana is offline
Mirth Newb
 
Join Date: Jun 2011
Location: Mataró (Barcelona)
Posts: 24
mlizana is on a distinguished road
Cool [SOLVED] Adjust param names and namespaces

Hi, finally I found the solution, that is changing appropiatelly the param names and namespaces for each param in the web service method, according to the WSDL specification:

Code:
@WebMethod(operationName = "MA44")
public String MA44(@WebParam(name="MensEntrada",targetNamespace="http://CCI.Servicios/") String message) {
		return webServiceMessageReceiver.processData(message);
	}
I changed name of the message param to "MensEntrada" and target namespace to fit "cci" namespace, as described in the WSDL.
Reply With Quote
  #7  
Old 07-19-2018, 04:12 PM
cadu cadu is offline
What's HL7?
 
Join Date: Jul 2018
Posts: 1
cadu is on a distinguished road
Default

Hi,

I have the exact same problem as mlizana before the last reply. I'm researching about this for the past 2 days with no luck yet.

Unfortunately the last comment doesn't really give the answer. The pasted code is the same as it was before. However, it seems correct as per the instructed solution (use the correct name and namespace for each parameter), as it seemed to mlizana in the previous to last comment.

I've tried running the code with the provided wsdl validated and the same xml message, and still get the empty value.

If anyone can help with this, I would be most grateful. I'm in a tight spot because I must use a predefined WSDL for the listener.

Thanks,

Cadu
Reply With Quote
Reply

Tags
custom, jax-ws annotations, namespace, soap envelope, web service listener

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 06:13 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation