Android Webservice Ingtegration SOAP

D

Djordan

Neues Mitglied
0
:wubwub:Hallo Leute,

wegen einem Uni-Projekt versuche ich schon seit Wochen das Tutorial TempConvert Web Service zu machen aber es gelingt mir immer nicht. Wenn ich versuche die Seite Bing zu aufzurufen, kommt immer Bing. Jetzt möchte ich mal fragen, ob das Tuto noch aktuell ist oder nicht. wenn es doch noch aktuell ist, was mache ich denn falsch.

Für das Uni Projekt muss ich eine ScannApps entwickeln, womit man eine Artikelnummer scannen kann, Artikelname und Artikeleinheit per Hand eingeben kann und dann in SAP aschickt. Die WSDL-Datei liegt schon vor und mit der Apps kann man schon scannen und die Nummer kriegen. Jetzt fehlt der Serviceaufruf.

ich bitte um Hilfe, ich habe schon Kopfschmerzen:confused2: von Suchen.

Vielen Dank

Djordan
 
Zuletzt bearbeitet:
soviel ich weiss, ist Namespace die Adresse einer Webseite
 
Namensräume werden durch URIs dargestellt, meistens also durch normale Webadressen. Dabei ist zu beachten, dass die entsprechende Adresse nicht existieren muss. Sie kann beliebig definiert werden.
http://de.wikipedia.org/wiki/Namensraum_(XML)

Für den Hintergrund/die Spezifikation:
Namespaces in XML 1.0 (Third Edition)

Zusammengefasst: 1. Namespaces müssen keine URLs sein, sondern sind URIs (das ist unterschiedlich)
2. Sollte eine URL als URI verwendet werden, muss unter der URL nichts erreichbar sein. Das führt zur nächsten Frage: Warum willst du tempuri.org aufrufen? Was erhoffst du dir da zu finden?
 
eigentlich wollte ich nur das Tuto für CelsiusToFahrenheit machen und nach mehreren ungelungenen Versuchen habe ich nicht verstanden warum es bei mir nicht geklappt hat, obwohl ich das Tuto mehrmal wiederholt habe sogar von verschiedenen Tutos. Dann habe ich gedacht, vielleicht sind die URL, Namespace und und nicht mehr aktuell sind, so habe ich versucht, die webseite tempuri.org aufzurufen.

eigentlich will ich meine Android Apps mit einer fertig gestellte Webservice integrieren.

- die Apps hat folgende Felder:
Materialname
Materialeinheit
Materialnummer (diese wird mit BarcodScanner erfasst)

und die WSDL Datei sieht folgende Masse aus:
<?xml version="1.0" encoding="UTF-8"?>

-<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:p1="http://de.sap-ucc.md.TR16" targetNamespace="http://de.sap-ucc.md.TR16" name="interface_inventarliste">
<wsdl:documentation/>
<wsp:UsingPolicy wsdl:required="true"/>
<wsp:policy wsu:Id="OP_interface_inventarliste"/>
-<wsdl:types>
-<xsd:schema targetNamespace="http://de.sap-ucc.md.TR16" xmlns="http://de.sap-ucc.md.TR16" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="inventarliste" type="inventarliste"/>
-<xsd:complexType name="gegenstand">
-<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/VersionID">f98255ead9aa11e281450000073d2d16</xsd:appinfo>
</xsd:annotation>
-<xsd:sequence>
-<xsd:element name="name" type="xsd:string">
-<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">c9237611d75411e2c7cf0040055746a0</xsd:appinfo>
</xsd:annotation>
</xsd:element>
-<xsd:element name="anzahl">
-<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">c9238c5cd75411e2ccdf0040055746a0</xsd:appinfo>
</xsd:annotation>
-<xsd:complexType>
-<xsd:simpleContent>
-<xsd:extension base="xsd:positiveInteger">
-<xsd:attribute name="einheit">
-<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">c9238c5bd75411e2b6f40040055746a0</xsd:appinfo>
</xsd:annotation>
-<xsd:simpleType>
-<xsd:restriction base="xsd:string">
<xsd:enumeration value="stck"/>
<xsd:enumeration value="pkg"/>
<xsd:enumeration value="l"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
-<xsd:attribute name="id" type="xsd:string" use="required">
-<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">c9238c5dd75411e2b3cf0040055746a0</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
-<xsd:complexType name="posten">
-<xsd:annotation>
<xsd:appinfosource="http://sap.com/xi/VersionID">1c42bdb2d75511e2ce950000073d2d16</xsd:appinfo>
</xsd:annotation>
-<xsd:sequence>
-<xsd:element name="gegenstand" type="gegenstand" maxOccurs="unbounded">
-<xsd:annotation>
<xsd:appinfosource="http://sap.com/xi/TextID">1b3199eed75511e2bf870040055746a0</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
-<xsd:complexType name="inventarliste">
-<xsd:annotation>
<xsd:appinfosource="http://sap.com/xi/VersionID">555365a2d75511e2a8920000073d2d16</xsd:appinfo>

</xsd:annotation>
-<xsd:sequence>
-<xsd:element name="posten" type="posten">
-<xsd:annotation>
<xsd:appinfosource="http://sap.com/xi/TextID">5e958ae2d75511e2aeb60040055746a0</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
-<xsd:attribute name="id" type="xsd:int">
-<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">5e95ae9ad75511e28e130040055746a0</xsd:appinfo>

</xsd:annotation>
</xsd:attribute>
-<xsd:attribute name="datum" type="xsd:date">
-<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">5e95ae9bd75511e28f500040055746a0</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
-<wsdl:message name="inventarliste">
<wsdl:documentation/>
<wsdl:part name="inventarliste" element="p1:inventarliste"/>
</wsdl:message>
-<wsdl:portType name="interface_inventarliste">
<wsdl:documentation/>
-<wsdl:operation name="interface_inventarliste">
<wsdl:documentation/>
-<wsp:policy>
<wsp:policyReference URI="#OP_interface_inventarliste"/>
</wsp:policy>
<wsdl:input message="p1:inventarliste"/>
</wsdl:operation>
</wsdl:portType>
-<wsdl:binding name="interface_inventarlisteBinding" type="p1:interface_inventarliste">
<soap:binding xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
-<wsdl:operation name="interface_inventarliste">
<soap:operation xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="http://sap.com/xi/WebService/soap1.1"/>
-<wsdl:input>
<soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
-<wsdl:service name="interface_inventarlisteService">
-<wsdl:port name="HTTP_Port" binding="p1:interface_inventarlisteBinding">
<soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" location="http://r12z.hcc.uni-magdeburg.de:51200/XISOAPAdapter/MessageServlet?senderParty=&senderService=TR_16_App&receiverParty=&receiverService=&interface=interface_inventarliste&interfaceNamespace=http%3A%2F%2Fde.sap-ucc.md.TR16"/>
</wsdl:port>
-<wsdl:port name="HTTPS_Port" binding="p1:interface_inventarlisteBinding">
<soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" location="https://r12z.hcc.uni-magdeburg.de:51201/XISOAPAdapter/MessageServlet?senderParty=&senderService=TR_16_App&receiverParty=&receiverService=&interface=interface_inventarliste&interfaceNamespace=http%3A%2F%2Fde.sap-ucc.md.TR16"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
 
ja genau um die Seite aufzurufen muss sich man anmelden.
Nach anmelden bekommt man folgendes:

Message Servlet is in Status OK
Status information:
Servlet com.sap.aii.adapter.soap.web.MessageServlet (Version $Id: //tc/xpi.adapters/NW730EXT_07_REL/src/_soap_application_web_module/webm/api/com/sap/aii/adapter/soap/web/MessageServlet.java#1 $) bound to /MessageServlet
Classname ModuleProcessor: null
Lookupname for localModuleProcessorLookupName: localejbs/ModuleProcessorBean
Lookupname for remoteModuleProcessorLookupName: null
ModuleProcessorClass not instantiated
ModuleProcessorLocal is Instance of $Proxy625
ModuleProcessorRemote not instantiated
 
Ja die Frage ist ob du bei deinem Webservice-Aufruf auch eine Authentifizierung vornimmst. Soll heißen, authentifiziert die App sich gegenüber dem Service?
 
Ja die apps muss sich bei jedem serviceaufruf identifieren.
 
hallo kleinerkathe,

könntest du mir bei diesem Problem noch helfen? ich hocke dran ca. vier Stunden am Tag und es hat bis jetzt nichts gebracht. Ich würde dir auch die Zugangsdaten mitteilen wenn nötig. Wenn ich mein Kode ausführe, wirft er mir immer eine Java.io.IOException zurück. Bitte um Hilfe:sad: :sad: :sad:

package com.example.inventarapps;
import java.io.IOException;
import java.net.SocketTimeoutException;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.kxml2.kdom.Element;
import org.kxml2.kdom.Node;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends ActionBarActivity {
private static final String SOAP_ACTION = "http://de.sap-ucc.md.TR16/interface_inventarliste";
private static final String METHOD_NAME = "interface_inventarliste";
private static final String NAMESPACE = "http://de.sap-ucc.md.TR16/";
private static final String URL = "http://r12z.hcc.uni-magdeburg.de:51200/XISOAPAdapter/MessageServlet?senderParty=;senderService=TR_16_App;receiverParty=;receiverService=;interface=interface_inventarliste;interfaceNamespace=http%3A%2F%2Fde.sap-ucc.md.TR16";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}

}

private Element buildAuthHeader() {
Element h = new Element().createElement(NAMESPACE, "AuthHeader");
Element username = new Element().createElement(NAMESPACE, "Username");
username.addChild(Node.TEXT, "TR-BWA-06");
h.addChild(Node.ELEMENT, username);
Element pass = new Element().createElement(NAMESPACE, "Password");
pass.addChild(Node.TEXT, "*********");
h.addChild(Node.ELEMENT, pass);

return h;
}

public void erfassen(View v) {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

// Set the property info for the to currency
PropertyInfo invId = new PropertyInfo();
invId.setName("inventarliste");
invId.setValue(12);
invId.setType(String.class);
request.addProperty(invId);

PropertyInfo datum = new PropertyInfo();
datum.setName("datum");
datum.setValue(" ");
datum.setType(String.class);
request.addProperty(datum);

PropertyInfo gegenstand = new PropertyInfo();
gegenstand.setName("gegenstand");
gegenstand.setValue("78562354");
gegenstand.setType(String.class);
request.addProperty(gegenstand);

PropertyInfo name = new PropertyInfo();
name.setName("name");
name.setValue("Mat");
name.setType(String.class);
request.addProperty(name);

PropertyInfo einheit = new PropertyInfo();
einheit.setName("einheit");
einheit.setValue("stk");
einheit.setType(String.class);
request.addProperty(einheit);

PropertyInfo anzahl = new PropertyInfo();
anzahl.setName("anzahl");
anzahl.setValue("1");
anzahl.setType(String.class);
request.addProperty(anzahl);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.headerOut = new Element[1];
envelope.headerOut[0] = buildAuthHeader();
envelope.setOutputSoapObject(request);

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
// SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
} catch (Exception e) {
Toast toast = Toast.makeText(getApplicationContext(), e.toString(),
Toast.LENGTH_SHORT);
toast.show();
}

}

// public void onClick(View v) {
// IntentIntegrator integra = new IntentIntegrator();
// integra.initiateScan(this);
// }
//
// public void onActivityResult(int requestCode, int resultCode, Intent intent) {
// IntentResult scanningResult = IntentIntegrator.parseActivityResult(
// requestCode, resultCode, intent);
// if (scanningResult != null) {
// String scanContent = scanningResult.getContents();
// ((EditText) findViewById(R.id.editText3)).setText(scanContent);
// } else {
// Toast toast = Toast.makeText(getApplicationContext(),
// "No scan data received!", Toast.LENGTH_SHORT);
// toast.show();
// }
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
//
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.main, menu);
// return true;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// // Handle action bar item clicks here. The action bar will
// // automatically handle clicks on the Home/Up button, so long
// // as you specify a parent activity in AndroidManifest.xml.
// int id = item.getItemId();
// if (id == R.id.action_settings) {
// return true;
// }
// return super.onOptionsItemSelected(item);
// }
//
// /**
// * A placeholder fragment containing a simple view.
// */
// public static class PlaceholderFragment extends Fragment {
//
// public PlaceholderFragment() {
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Bundle savedInstanceState) {
// View rootView = inflater.inflate(R.layout.fragment_main, container,
// false);
// return rootView;
// }
// }

}


- Die Ausführung der wsdl-Datei ergibt folgendes in SOAPUI:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:de="http://de.sap-ucc.md.TR16">
<soapenv:Header/>
<soapenv:Body>
<de:inventarliste id="?" datum="?">
<posten>
<!--1 or more repetitions:-->
<gegenstand id="?">
<name>?</name>
<anzahl einheit="?">?</anzahl>
</gegenstand>
</posten>
</de:inventarliste>
</soapenv:Body>
</soapenv:Envelope>
 

Ähnliche Themen

M
Antworten
4
Aufrufe
1.180
swa00
swa00
5
Antworten
0
Aufrufe
1.173
586920
5
B
Antworten
4
Aufrufe
518
bb321
B
Zurück
Oben Unten