Jump to content

Recommended Posts

Hi Guys/Gals,

 

I am new to PHP and when I say new, I mean I know a variable is $variable name... that is about it.

 

I am a .Net developer, always was, now I have to learn some php.

 

I have a .Net payment gateway service that I would like to reference

from a php site.

 

I was hoping anyone could point me in the right direction on how to go

about adding a .Net Service and pointing to it in PHP.

 

Please note this is a WPF service, thus it is a .svc page not a .asmx

and it is hosted and running on iis on a server.

 

Please some guidance? Any help would be appreciated.

Link to comment
https://forums.phpfreaks.com/topic/254722-php-point-to-net-service/
Share on other sites

I'm afraid most of us aren't familiar with .NET.  I've dabbled in webforms, and do MVC work (C# for both), but haven't touched WPF.

 

How is this supposed to work?  Can the WPF component simply accept POST data, or is there more to it?  What should the PHP side do?

As far as I know it does ASYNC calls so no posting should happen.

 

I know in .Net in the WebConfig you have to add a ServiceReference kinda like this:

<behaviors>

            <serviceBehaviors>

                <behavior name="">

                    <serviceMetadata httpGetEnabled="true" />

                    <serviceDebug includeExceptionDetailInFaults="false" />

                </behavior>

            </serviceBehaviors>

        </behaviors>

        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

        <bindings>

            <basicHttpBinding>

                <binding name="BasicHttpBinding_IServiceNameService" closeTimeout="00:01:00"

                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

                    useDefaultWebProxy="true">

                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />

                    <security mode="None">

                        <transport clientCredentialType="None" proxyCredentialType="None"

                            realm="" />

                        <message clientCredentialType="UserName" algorithmSuite="Default" />

                    </security>

                </binding>

            </basicHttpBinding>

        </bindings>

        <client>

            <endpoint address="http://Server:Port/ServiceToPointTo.svc"

                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServiceNameService"

                contract="ServiceNameReference.IServiceNameService" name="BasicHttpBinding_IServiceNameService" />

        </client>

 

I have no idea how to replicate something like this

in PHP or if it is infact possible.

 

Most examples I get on google reffer to the .asmx service, NOT what I want.

I need and want the .svc service.

 

Thanx

PHP definitely doesn't have anything like that out of the box.  That said, I'm still a bit confused about how the components should interact.  What the workflow should be.  Is it as simple as just wanting to send some GET values from PHP to the service?

 

If you can expand on how the whole thing should work, I may be able to point you in the right direction.

okay, cool.

 

Basically, I want to say click on a button. The button's code will

call a php function which then in turn would call a function from the

.svc service. Once the function on the .svc is completed it would

send a response back to the php.

 

Ideally it should work like this:

Click on the button -> php calls the .svc service and waits for a response -> .svc function completes and send a response -> php continues depending on the response.

 

But this should happen without the page posting or refreshing or anything.

 

That is basically the flow.

 

Thanx.

Ah.  Basically, it would be:

 

JavaScript click event -> asynchronous call to PHP script -> PHP-to-service call* -> service processes the data* -> service-to-PHP* -> PHP-to-JavaScript

 

I'm not sure if what I listed with * will work the way you want.  It depends on what you mean for 'waits for a response.'  Also, depending on what the service expects, you may need to use cURL to send the data from PHP to it.

okay, lets put it like this:

 

I want to click on a button calling php,

the php then calls a function in the .Net Service called say getName with an ID parameter.

Then the site will wait for the .Net function to complete and send a response, in this case the name according to the id sent by php.

 

Depending on the response, the site will do something different.

 

Not sure f this makes it a bit more clear to what I want to do.

 

Thanx for the help

The service only requires the correct function to be called and the correct parameters

for that function to be returned.

 

It will return a string as a result or an integer, but nothing more 'intense'.

 

Please note, this service is a .svc file and it is hosted on IIS on a server.

The service must use some protocol that passes simple text as a request, it would then be this text which is used to trigger some function.

 

It might look like your imply calling "somefunction", but this would actually be wrapped within some other request. We need more details basically.

What more detail?

 

Basically, I have a compiled service with a couple functions one of which is getName(string ID).

The service is hosted on the IIS of a Windows Server 2008 R2.

 

I need the php to connect to this server, in .Net we use a ServiceReference to point to the server.

The php need to be able to access a function in the service, in this case, the getName function

and the PHP needs to send the ID parameter through to the service function.

 

Is this possible?

 

The second part to this is when the service returns a string with a value of a name

to the php.

The php then checks the name to see what should happen next

EXAMPLE:

If the name = 'John McTyre' then redirect site to page 3

if the name = 'Mike Johnson' then redirect site to page 8

 

I have thought about it and at the moment, I dont mind if the page

reloads or posts when this entire process occurs, for now, I just need

to be able to do the entire process. If it is possible.

The service reference creates the binding to the service and creates

a client with an endpoint:

<client>

            <endpoint address="http://Server:Port/ServiceToPointTo.svc"

                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServiceNameService"

                contract="ServiceNameReference.IServiceNameService" name="BasicHttpBinding_IServiceNameService" />

        </client>

 

Not sure what u mean with protocol, but I can point to the service using: http://Server:Port/ServiceToPointTo.svc

 

I have previously posted a sample of the code generated in the web.config by the ServiceReference.

 

Thanx

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.