Announcement

Collapse
No announcement yet.

Receiving SOAP Envelope in Custom Web Service

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 02:23 AM.

  • #2
    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.

    Comment


    • #3
      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>

      Comment


      • #4
        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?

        Comment


        • #5
          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:

          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

          Comment


          • #6
            [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.

            Comment


            • #7
              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

              Comment

              Working...
              X