Jump to content

wsdl help


severndigital

Recommended Posts

Hello.

 

I am trying to use this wsdl with PHP.

http://www.barcodesoft.com/bcdgen.asmx?WSDL

 

 

I used wsdl2php to generate the php file used. (see attached)

 

My question now is.. how do I actually use the generated webservice php file?

 

I know it should be something like

 

$barcode = new BarCodeWebService();
$barcode->some_function($someinfopassedin);
etc..
etc..

 

But how do I know what functions are to be used and what information I need to pass into the class?

 

I'm just wondering if someone can give me a working example of this. I tried to use the example on the wsdl2php website, but the webservice they reference does not seem to be in service anymore.

 

Thanks,

P

 

[attachment deleted by admin]

Link to comment
Share on other sites

Are you creating trying to create a webservice or connect to one?

 

I use PHP SOAP.

 

What I had to do was collect Customer details, payment details, send them to the Insurer and await a response. I.e. I was the client.

 

To check if the web service is working have a look at a program called SOAP UI. This will load a WSDL file into it and try to connect to it.  I found it quite easy to configure and get working (Espcially if the WSDL requires no authentication).

 

For the PHP side, have a look at SOAP requests, I can post some code if you wish though it may be not suited to your needs.

 

Link to comment
Share on other sites

$client = new SoapClient("http://www.barcodesoft.com/bcdgen.asmx?WSDL");

print_r($client->__getFunctions());

 

ok .. i did that. But it still doesn't tell me any thing... for example .. what do I pass along in $parameters? here is the output from that.

 

Array
(
    [0] => Code39Response Code39(Code39 $parameters)
    [1] => Code39ExtResponse Code39Ext(Code39Ext $parameters)
    [2] => CodabarResponse Codabar(Codabar $parameters)
    [3] => I25Response I25(I25 $parameters)
    [4] => Code93Response Code93(Code93 $parameters)
    [5] => Code128AResponse Code128A(Code128A $parameters)
    [6] => Code128BResponse Code128B(Code128B $parameters)
    [7] => Code128CResponse Code128C(Code128C $parameters)
    [8] => Code25Response Code25(Code25 $parameters)
    [9] => Code11Response Code11(Code11 $parameters)
    [10] => TelepenResponse Telepen(Telepen $parameters)
    [11] => MSIResponse MSI(MSI $parameters)
    [12] => POSTNETResponse POSTNET(POSTNET $parameters)
    [13] => UPCAResponse UPCA(UPCA $parameters)
    [14] => UPCEResponse UPCE(UPCE $parameters)
    [15] => EAN13Response EAN13(EAN13 $parameters)
    [16] => EAN8Response EAN8(EAN8 $parameters)
    [17] => BOOKLANDResponse BOOKLAND(BOOKLAND $parameters)
    [18] => DatamatrixResponse Datamatrix(Datamatrix $parameters)
    [19] => QRCodeResponse QRCode(QRCode $parameters)
    [20] => Pdf417Response Pdf417(Pdf417 $parameters)
    [21] => AztecResponse Aztec(Aztec $parameters)
    [22] => Code39Response Code39(Code39 $parameters)
    [23] => Code39ExtResponse Code39Ext(Code39Ext $parameters)
    [24] => CodabarResponse Codabar(Codabar $parameters)
    [25] => I25Response I25(I25 $parameters)
    [26] => Code93Response Code93(Code93 $parameters)
    [27] => Code128AResponse Code128A(Code128A $parameters)
    [28] => Code128BResponse Code128B(Code128B $parameters)
    [29] => Code128CResponse Code128C(Code128C $parameters)
    [30] => Code25Response Code25(Code25 $parameters)
    [31] => Code11Response Code11(Code11 $parameters)
    [32] => TelepenResponse Telepen(Telepen $parameters)
    [33] => MSIResponse MSI(MSI $parameters)
    [34] => POSTNETResponse POSTNET(POSTNET $parameters)
    [35] => UPCAResponse UPCA(UPCA $parameters)
    [36] => UPCEResponse UPCE(UPCE $parameters)
    [37] => EAN13Response EAN13(EAN13 $parameters)
    [38] => EAN8Response EAN8(EAN8 $parameters)
    [39] => BOOKLANDResponse BOOKLAND(BOOKLAND $parameters)
    [40] => DatamatrixResponse Datamatrix(Datamatrix $parameters)
    [41] => QRCodeResponse QRCode(QRCode $parameters)
    [42] => Pdf417Response Pdf417(Pdf417 $parameters)
    [43] => AztecResponse Aztec(Aztec $parameters)
)

 

Thanks for any and all help.

 

P

Link to comment
Share on other sites

$parameters will be defined in the actual WDSL itself, you will need to run through that to gain an understanding of what you need to pass over. I had to do it several times with my own to fulyl understand what it was asking.

 

I.e. for Code 39 it requires the followsing elements to be passed over

 

<s:element name="Code39">
−
<s:complexType>
−
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="textToEncode" type="s:string"/>  
<s:element minOccurs="1" maxOccurs="1" name="ShowHumanReadable" type="s:boolean"/>
<s:element minOccurs="1" maxOccurs="1" name="ShowCheckDigit" type="s:boolean"/>
<s:element minOccurs="1" maxOccurs="1" name="ImageFormat" type="tns:BcsImageFormat"/>
<s:element minOccurs="1" maxOccurs="1" name="Orientation" type="tns:BcsOrientation"/>
<s:element minOccurs="1" maxOccurs="1" name="BarWidth" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="BarHeight" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>

Link to comment
Share on other sites

yeah .. i started to fumble through it.

 

I am little confused on one part though

 

that is the functions that are returned from in the array, I don't understand how to access them....

 

here is what I have going so far..

I am trying to use the function UPCAResponse UPCA(UPCA $parameters)..which according to the wsdl has this listed...

 

<s:element name="UPCA">
−
<s:complexType>
−
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="textToEncode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="strAddon" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="ImageFormat" type="tns:BcsImageFormat"/>
<s:element minOccurs="1" maxOccurs="1" name="Orientation" type="tns:BcsOrientation"/>
<s:element minOccurs="1" maxOccurs="1" name="BarWidth" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="BarHeight" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
−
<s:element name="UPCAResponse">
−
<s:complexType>
−
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="UPCAResult" type="s:base64Binary"/>
</s:sequence>
</s:complexType>
</s:element>

 

 

 

   $client = new SoapClient("http://www.barcodesoft.com/bcdgen.asmx?WSDL");
   print_r($client->__getFunctions());
   $paras = array(
                  'textToEncode'=>'9783540235606',
                  'ImageFormat'=>'PNG',
                  'strAddon'=>'',
                  'Orientation'=>'Original',
                  'Bar Width'=>'2',
                  'Bar Height'=>'10'
            );

//I don't understand how to access those function .. I have tried the following.

echo $client->UPCAResponse($paras); // no good

//also

$client->UPCA($paras);
echo $client->UPCAResponse(); // no good

 

Sorry to be a bother, I am just having a really hard time understanding these wsdl things.

 

thanks again for all the help.

 

P

Link to comment
Share on other sites

Hi

 

Please see the below screenshot of your WDSL in Soap UI. Soap UI will connect to your WSDL and send requests quite similar to PHP, its very helpful in finding out what you need to send in order to get it to work.

 

You will also get a response from the server.

 

To set this up all I had to do was click on File -> New SOAP UI Project

 

A little window pops up asking you for the URL to your WDSL, enter that, press OK and it all starts working.

 

Honestly best way to go to make head and tail of whats needed. (Sorry for big pic)

 

Tip - See the little Red Arrow under the Request 1 Title. Press that to simulate a request, to change the data your sending across, modify the details in the left hand window pane.

 

You are going the right way about it with that PHP array you did before, it may just take some playing around to get it work correctly, at least with Soap UI you can pinpoint where your going wrong.

 

[attachment deleted by admin]

Link to comment
Share on other sites

Bar Width and Bar Height is one word not 2

 

BarWidth

BarHeaigh

 

in the array.

 

   $client = new SoapClient("http://www.barcodesoft.com/bcdgen.asmx?WSDL");
   $response = $client->UPCA(array(
                  'textToEncode'=>'9783540235606',
                  'ImageFormat'=>'PNG',
                  'strAddon'=>'',
                  'Orientation'=>'Original',
                  'BarWidth'=>'2',
                  'BarHeight'=>'10'
           ));

print_r($response );

Link to comment
Share on other sites

WHOO HOO! .. We got it working ..

 

my final code was

<?php

   $client = new SoapClient("http://www.barcodesoft.com/bcdgen.asmx?WSDL");
   //print_r($client->__getFunctions());
   $paras = array(
                  'textToEncode'=>'9789764574009',
                  'ImageFormat'=>'PNG',
                  'strAddon'=>'',
                  'Orientation'=>'Original',
                  'BarWidth'=>'2',
                  'BarHeight'=>'80'
            );
  $response =  $client->UPCA($paras);
header('Content-Type: image/png');
echo  $response->UPCAResult;
?>

 

Thanks again to everyone .. you have made my understanding of WSDL's much better.

P

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.