Hi All,
i have next problem, i trying to play with service, that give some
MIME binary data back.
i have make client with folowing code, and it’s not work…..i got following exception
inside invokeBlocking() method. i could monitor both request and response soap
envelopes properly via the tcp monitor.
what made i wrong?
king reguards,
filipp
public static TFaxReceiveResponse getFaxReceive() throws AxisFault {
TFaxReceiveResponse response = null;
try {
Call call = new Call();
call.setTo(targetEPR);
// enabling MTOM
call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
call.setTransportInfo(Constants.TRANSPORT_HTTP,
Constants.TRANSPORT_HTTP, false);
try {
MessageContext requestContext = FaxReceive.request(new
TFaxReceive(account, password));
QName opName = new QName("urn:XMLWSIntf-IXMLWS", "FaxReceive");
OperationDescription opdesc = new OperationDescription(opName);
//Blocking invocation
MessageContext result = (MessageContext) call.invokeBlocking(opdesc
,requestContext);
response = FaxReceive.response(result);
} catch (Exception e) {
if(debug)e.printStackTrace();
}
} catch (AxisFault axisFault) {
if(debug)axisFault.printStackTrace();
}
return response;
}
Exception:
org.apache.axis2.AxisFault: null; nested exception is:
_java.lang.NullPointerException_
at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(_TransportUtils.java:96_)
at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(_TransportUtils.java:46_)
at
org.apache.axis2.clientapi.TwoWayTransportBasedSender.send(_TwoWayTransportBasedSender.java:54_)
at
org.apache.axis2.clientapi.InOutMEPClient.invokeBlocking(_InOutMEPClient.java:174_)
at
de.fax.soap.axis2.client.FaxDeClient.getFaxReceive(_FaxDeClient.java:344_)
at de.fax.soap.axis2.client.FaxDeClient.main(_FaxDeClient.java:164_)
Caused by: _java.lang.NullPointerException_
at
org.apache.axis2.attachments.MIMEHelper.getAttachmentSpecType(_MIMEHelper.java:165_)
at
org.apache.axis2.transport.http.HTTPTransportUtils.selectBuilderForMIME(_HTTPTransportUtils.java:345_)
at
org.apache.axis2.transport.TransportUtils.createSOAPMessage(_TransportUtils.java:73_)
... 5 more
public class FaxReceive extends RequestResponse{
public static MessageContext request(TFaxReceive faxReceive) throws
AxisFault{
OMElement operation;
MessageContext msgContext = null;
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = factory.getDefaultEnvelope();
envelope.declareNamespace("http://schemas.xmlsoap.org/soap/envelope/",
"soapenv");
envelope.declareNamespace("http://schemas.xmlsoap.org/soap/encoding/",
"SOAP-ENC");
envelope.declareNamespace("http://www.w3.org/2001/XMLSchema-instance",
"xsi");
OMNamespace ns1 = factory.createOMNamespace("urn:XMLWSIntf-IXMLWS","NS1");
operation = factory.createOMElement("Status",ns1);
envelope.getBody().addChild(operation);
OMNamespace ns2 =
operation.declareNamespace("http://www.w3.org/2001/XMLSchema","");
operation.addChild(getOMElement(factory, ns2, "Account", "xsd:string",
faxReceive.getAccount()));
operation.addChild(getOMElement(factory, ns2, "Password",
"xsd:string", faxReceive.getPassword()));
ConfigurationContextFactory fac = new ConfigurationContextFactory();
ConfigurationContext configContext =
fac.buildClientConfigurationContext("Status");
try {
msgContext = new MessageContext(configContext);
} catch (AxisFault axisFault) {
axisFault.printStackTrace();
}
msgContext.setEnvelope(envelope);
if(debug)debugMessageContext(msgContext);
return msgContext;
}
public static TFaxReceiveResponse response(MessageContext result) {
// if(debug)debugMessageContext(result);
int ret = -1;
Iterator iterator;
OMNode node;
SOAPBody body;
OMElement operation, elem;
SOAPEnvelope resEnvelope;
resEnvelope = result.getEnvelope();
body = resEnvelope.getBody();
operation = resEnvelope.getBody();
// operation = body.getFirstElement();
if (body.hasFault()) {
if(debug)System.out.println("Error");
} else {
OMElement part = operation.getFirstElement();
iterator = part.getChildren();
while (iterator.hasNext()) {
node = (OMNode) iterator.next();
if (node.getType() == OMNode.ELEMENT_NODE) {
elem = (OMElement) node;
String str = elem.getLocalName();
System.out.println("elem Name:" + str);
if (str.equals("return")) {
ret = new Integer(elem.getText()).intValue();
if(debug)System.out.println("return:" + elem.getText());
}else if(str.equals("Protokoll")) {
// OMElement child = (OMElement)elem.getFirstChild();
//retreiving the Href attribute which contains the Content Id
OMAttribute attr = (OMAttribute)elem.getFirstAttribute(new QName("href"));
String contentID = attr.getValue();
//content-id processing to remove the "cid" prefix
contentID = contentID.trim();
if (contentID.substring(0, 3).equalsIgnoreCase("cid")) {
contentID = contentID.substring(4);
}
// Retrieving the MIMEHelper instance (which contains reference to
attachments)
// from the Message Context
// MIMEHelper attachments =
(MIMEHelper)result.getProperty(MIMEHelper.ATTACHMENTS);
///^^^^^^^^^^^^ MIMEHelper.ATTACHMENTS -> CANNOT BE RESOLVED
!!!!!!!!!!!!!!!!!!!!!!! ?!?!?!?
// Retrieving the respective DataHandler referenced by the content-id
// DataHandler dataHandler = attachments.getDataHandler(contentID);
// OMText binaryNode = (OMText) elem.getFirstChild();
}
}
}
}
return new TFaxReceiveResponse(ret);
}
POST /xmlws.exe/soap/IXMLWS HTTP/1.1
User-Agent: Axis/2.0
SOAPAction:
Connection: Keep-Alive
Host: ccs.fax.de:80
Content-Length: 507
Content-Type: text/xml; charset=utf-8
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header></soapenv:Header>
<soapenv:Body>
<NS1:Status xmlns:NS1="urn:XMLWSIntf-IXMLWS"
xmlns="http://www.w3.org/2001/XMLSchema">
<Account xsi:type="xsd:string">1234567890</Account>
<Password xsi:type="xsd:string">ABCDEF</Password>
</NS1:Status>
</soapenv:Body>
</soapenv:Envelope>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
HTTP/1.1 100 Continue
Server: Microsoft-IIS/5.0
Date: Tue, 20 Sep 2005 22:14:30 GMT
X-Powered-By:: ASP.NET
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Tue, 20 Sep 2005 22:14:30 GMT
X-Powered-By:: ASP.NET
Connection: close
Content-Version: MIME-Version: 1.0
Content-Type: multipart/related;
boundary=MIME_boundaryB0R9532143182121;
start="<http://www.borland.com/rootpart.xml>"Content-Length:
759Content:--MIME_boundaryB0R9532143182121Content-Type: text/xml;
charset="utf-8"Content-ID:
<http://www.borland.com/rootpart.xml>Content-Location:
http://www.borland.com/rootpart.xmlContent-Length: 517
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body
SOAP-ENC:encodingStyle="http://schemas.xmlsoap.org/soap/envelope/">
<NS1:StatusResponse xmlns:NS1="urn:XMLWSIntf-IXMLWS">
<return xsi:type="xsd:int">5</return>
<Protokoll xsi:nil="true"/>
</NS1:StatusResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>--MIME_boundaryB0R9532143182121—
=============================================================================================================