1

XML を変換して、引数として文字列の形式で XML ファイルを受信して​​いる Web サービスに送信したいのですが、以前に XML を送信していたオブジェクトのインスタンスに送信されていない Web サービス オブジェクト参照によってエラーが発生しています。 Web サービスと応答として XML を受信します。

これは私が使用しているコードです:

    private static String Soap_Action = "http://portal.ordernet.net/RequestorderStringg";
    private static String namespace = "http://portal.ordernet.net";
    private static String methodName = "RequestorderString";
    private static String URL = "https://portal.ordernet.net/WebServiceorderNotice.asmx";

    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
                    .newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory
                    .newDocumentBuilder();
    Document document = documentBuilder.newDocument();

    Element rootElement = document.createElement("dmi:ShipNoticeRequest");
    rootElement.setAttribute("xmlns:dmi",  "http://portal.suppliesnet.net");

    document.appendChild(rootElement);



    Element ContactElement =  document.createElement("dmi:RequesterISA");         
    rootElement.appendChild(ContactElement);
    ContactElement.appendChild(document.createTextNode("123456789012345"));

    Element articleElement = document.createElement("dmi:ShipDateRange");

    Element ShipDateFrom = document.createElement("dmi:ShipDateFrom");
    articleElement.appendChild(ShipDateFrom);
    ShipDateFrom.appendChild(document.createTextNode("2012-06-14"));

    Element ShipDateTo  = document.createElement("dmi:ShipDateTo");
    articleElement.appendChild(ShipDateTo);
    ShipDateTo.appendChild(document.createTextNode("2012-06-15"));

    rootElement.appendChild(articleElement);
    TransformerFactory factory = TransformerFactory.newInstance();
    Transformer transformer = factory.newTransformer();
    Properties outFormat = new Properties();
    outFormat.setProperty(OutputKeys.INDENT, "yes");
    outFormat.setProperty(OutputKeys.METHOD, "xml");
    outFormat.setProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
    outFormat.setProperty(OutputKeys.VERSION, "1.0");
    outFormat.setProperty(OutputKeys.ENCODING, "UTF-8");
    transformer.setOutputProperties(outFormat);
    DOMSource domSource = new DOMSource(document.getDocumentElement());
    OutputStream output = new ByteArrayOutputStream();
    StreamResult result = new StreamResult(output);
    transformer.transform(domSource, result);
    xmlString = output.toString();

        } catch (ParserConfigurationException e) {
        } catch (TransformerConfigurationException e) {
        } catch (TransformerException e) {
        }
     SoapObject request = new SoapObject(namespace, methodName);
    request.addProperty("RequestShipmentNoticeString", xmlString);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);

    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);
        // envelope.headerIn.
    final HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    androidHttpTransport.debug = true;
    try {
    androidHttpTransport.call(Soap_Action, envelope);
    SoapObject SoapResult = (SoapObject)envelope.bodyIn;
    tv.setText("Status" + SoapResult);
    } catch (Exception ex) {
    ex.printStackTrace();
    Log.e("static", "Exception in making call to server");
    }
4

0 に答える 0