Einzelnen Beitrag anzeigen
  #7  
Alt 04.08.2009, 11:10:00
rencarl rencarl ist offline
Anfänger
 
Registriert seit: Jul 2009
Alter: 50
Beiträge: 9
AW: Webservice mit PHP 5: Request Probleme

Zurück zum eigentlichen Thema:

Ich habe mittlerweile Login-Daten bekommen und eine Beispielanfrage, allerdings in Java
Code:
package com.deltavista.app.portal.soap.ordercheck.test;

import java.rmi.RemoteException;

import com.deltavista.app.portal.soap.ordercheck.ErrorMessage;
import com.deltavista.app.portal.soap.ordercheck.OrderCheckServiceStub;
import com.deltavista.app.portal.soap.ordercheck.stub.Address;
import com.deltavista.app.portal.soap.ordercheck.stub.Country;
import com.deltavista.app.portal.soap.ordercheck.stub.Credentials;
import com.deltavista.app.portal.soap.ordercheck.stub.LegalForm;
import com.deltavista.app.portal.soap.ordercheck.stub.Location;
import com.deltavista.app.portal.soap.ordercheck.stub.MessageContext;
import com.deltavista.app.portal.soap.ordercheck.stub.MessageContextE;
import com.deltavista.app.portal.soap.ordercheck.stub.OrderCheckRequest;
import com.deltavista.app.portal.soap.ordercheck.stub.OrderCheckRequestE;
import com.deltavista.app.portal.soap.ordercheck.stub.OrderCheckResponseE;
import com.deltavista.app.portal.soap.ordercheck.stub.Product;
import com.deltavista.app.portal.soap.ordercheck.stub.SearchCandidate;

/**
 * Send test request
 *
 * German Team, (c) Deltavista 2000-2009
 */

public class ExampleRequest {

	protected final static String host = "..."; 	  //TODO set proper host here
	protected final static String user="..."; 		//TODO set proper user login here 
	protected final static String password="..."; 	//TODO set proper user password here
	
	protected void testB2BRequest() throws RemoteException, ErrorMessage {
		
		Credentials credentials = new Credentials();
		credentials.setUser(user);
		credentials.setPassword(password);
		
		
		MessageContextE context = new MessageContextE();
		MessageContext ctx = new MessageContext();
		ctx.setCredentials(credentials);
		ctx.setCorrelationID("1234567890");
		context.setMessageContext(ctx);
		
		
		OrderCheckRequestE reqe  = new OrderCheckRequestE();
		Country country = new Country();
		country.setCountry("DEU");
		
		OrderCheckRequest req = new OrderCheckRequest();
		Product product = new Product();
		product.setName("CreditCheckBusiness");
		product.setCountry(country);
		req.setProduct(product);
		
		SearchCandidate candidate = new SearchCandidate();
		candidate.setLegalForm(LegalForm.COMPANY);
		
		
		Address address = new Address();
		address.setName("Deltavista");
		Location[] locationArray = new Location[1];
		Location location = new Location();
		location.setType("CURRENT");
		location.setCity("Karlsruhe");
		location.setStreet("Keiserstr.");
		location.setHouse("217");
		location.setZip("76133");
		Country candidateCountry = new Country();
		candidateCountry.setCountry("DEU");
		location.setCountry(candidateCountry);
		locationArray[0] = location;
		address.setLocation(locationArray);
		
		candidate.setAddress(address);
		
		
		req.setSearchedCandidate(candidate);
		reqe.setOrderCheckRequest(req);
		
		
		OrderCheckServiceStub stub = new OrderCheckServiceStub(host);
		stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(200000);
		OrderCheckResponseE response;
		
		response = null;
		try {
			response = stub.orderCheck(reqe, context);
		} catch (RemoteException e) {
			System.out.println("RemoteException: " + e + "\n" + e.getMessage());
			throw e;
		} catch (ErrorMessage e) {
			System.out.println("ErrorMessage exception: " + e + "\n" + e.getMessage());
			if (e.getFaultMessage() != null && e.getFaultMessage().getError() != null) {
				System.out.println("Error code= " + e.getFaultMessage().getError().getCode() + ": " + e.getFaultMessage().getError().getMessageText());
			}
			throw e;
		}
	}

	protected void testB2CRequest() throws RemoteException, ErrorMessage {
		
		Credentials credentials = new Credentials();
		credentials.setUser(user);
		credentials.setPassword(password);
		
		MessageContextE context = new MessageContextE();
		MessageContext ctx = new MessageContext();
		ctx.setCredentials(credentials);
		ctx.setCorrelationID("1234567890");
		context.setMessageContext(ctx);
		
		
		OrderCheckRequestE reqe  = new OrderCheckRequestE();
		Country country = new Country();
		country.setCountry("DEU");
		
		OrderCheckRequest req = new OrderCheckRequest();
		Product product = new Product();
		product.setName("CreditCheckConsumer");
		product.setCountry(country);
		req.setProduct(product);
		
		SearchCandidate candidate = new SearchCandidate();
		candidate.setLegalForm(LegalForm.PERSON);
		
		Address address = new Address();
		address.setName("Max Mustermann");
		Location[] locationArray = new Location[1];
		Location location = new Location();
		location.setType("CURRENT");
		location.setCity("Musterstadt");
		location.setStreet("Musterstraße");
		location.setHouse("1");
		location.setZip("12345");
		Country candidateCountry = new Country();
		candidateCountry.setCountry("DEU");
		location.setCountry(candidateCountry);
		locationArray[0] = location;
		address.setLocation(locationArray);
		
		candidate.setAddress(address);
		
		
		req.setSearchedCandidate(candidate);
		reqe.setOrderCheckRequest(req);
		
		
		OrderCheckServiceStub stub = new OrderCheckServiceStub(host);
		stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(200000);
		OrderCheckResponseE response;
		
		response = null;
		try {
			response = stub.orderCheck(reqe, context);
		} catch (RemoteException e) {
			System.out.println("RemoteException: " + e + "\n" + e.getMessage());
			throw e;
		} catch (ErrorMessage e) {
			System.out.println("ErrorMessage exception: " + e + "\n" + e.getMessage());
			if (e.getFaultMessage() != null && e.getFaultMessage().getError() != null) {
				System.out.println("Error code= " + e.getFaultMessage().getError().getCode() + ": " + e.getFaultMessage().getError().getMessageText());
			}
			throw e;
		}
	}

}
Mit Java kann ich nun überhaupt nix anfangen. Der Webservice wird doch aber mittels XML bewerkstelligt. Also müsste es doch möglich sein aus dem Java-Code den nötigen PHP-Code zu interpretieren. Das habe ich auch versucht:
PHP-Code:
$client = new SOAPClient('https://online-de.deltavista.com/dspone/services/OrderCheckService?wsdl', array("user" => "MEINUSERNAME""password" => "MEINPASSWORT"));

// Gibt eine Liste verfügbarer SOAP-Funktionen zurück
print_r($client->__getFunctions());
echo 
'<hr>';

// Gibt eine Liste der SOAP-Typen zurück
print_r($client->__getTypes());
echo 
'<hr>';

$parameter = array(
 
'product' => 'QuickCheckBusiness',
 
'company' => array(
   
'name' => 'Bau Clever GmbH',
   
'location' => array(
      
'street' => 'Rathaustraße',
      
'house' => '2',
      
'city' => 'Glücksburg',
      
'zip' => '24960')
   )
);

$result $client->__soapCall("orderCheck"$parameter);

if(
is_soap_fault($result)) {
    echo 
"FehlerCode: "$result->faultcode"\n";
    echo 
"Beschreibung: "$result->faultstring"\n";
    echo 
"Sender: "$result->faultactor"\n";
} else {
    
print_r($result);
}
echo 
"<hr>ANFRAGE:\n" .$client->__getLastRequest(). "\n";
echo 
"<hr>ANTWORT:\n" .$client->__getLastResponse(). "\n"
Als Ergebnis bekomme ich 'Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in ....'

Sorry, wenn ich alles mit Code zumülle, aber ich weiß echt nicht weiter.

Meine Testseite mit kompletter Ausgabe: http://www.teekontor-ostfriesland.de/client.php
Mit Zitat antworten